[Domain Mapping] NBT Gravity Form integration hook to show specific template is not working

At this thread you guys gave a code to show just a specific template at a chosen Gravity Forms form: https://premium.wpmudev.org/forums/topic/select-a-specific-new-blog-template-using-gravity-forms#post-1206937
However, it is not really working. It just shows the templates instead the checkbox input field, but nothing happens if I chose a specific template there. But I don`t want just a specific template either. I would like, actually, to be able to choose a specific template category to bring its templates attached at my chosen form. Below is the given thread hook code. What should I change in it in order to get that?

<?php

add_filter( 'gform_userregistration_feed_settings_fields', function( $settings ) {
	if ( ! function_exists( 'nbt_get_model' ) )
		return $settings;

	$model = nbt_get_model();
	$templates = $model->get_templates();
	$choices = array(
		array(
			'label' => 'Select template',
			'value' => 0
		)
	);
	foreach ( $templates as $template_id => $template ) {
		$choices[] = array(
			'label' => esc_html( $template['name'] ),
			'value' => $template['ID']
		);
	}

	$settings['nbt'] = array(
		'title' => __( 'New Blog Templates', 'blog_templates' ),
		'description' => '',
		'dependency' => array(),
		'fields' => array(
			array(
				'name' => 'gf_user_registration_multisite_blog_templates_template_id',
				'label' => __( 'Template', 'blog_templates' ),
				'type' => 'select',
				'choices' => $choices
			)
		)
	);
	return $settings;
}, 50);

add_filter( 'gform_submit_button', 'nbt_hooks_render_hidden_form_field', 15, 2 );
function nbt_hooks_render_hidden_form_field( $button_input, $form ) {
	$user_registration = gf_user_registration();
	$config = $user_registration->get_feed( $form['id'] );
	$template_id = absint( rgar( $config['meta'], 'gf_user_registration_multisite_blog_templates_template_id' ) );

	if ( $template_id ) {

		if ( ! function_exists( 'nbt_get_model' ) )
			return $button_input;

		$model = nbt_get_model();

		if ( ! $model->get_template( $template_id ) )
			return $button_input;

		$button_input .= ' <input type="hidden" class="gform_hidden" name="blog_template" value="' . $template_id . '" />';

	}

	return $button_input;
}

Thank you very much! :wink:

  • Adam Czajczyk
    • Support Gorilla

    Hi diegpl

    I hope you're well today!

    I took a liberty of reassigning this ticket from "Domain Mapping" plugin to the "New Blog Templates" plugin as this seems to be more relevant to the case. I hope that's fine for you :slight_smile:

    The code is almost two years old and I think related hooks/code in Gravity Forms might have changed enough meanwhile. It's a custom code as there's no integration for Gravity Forms built-in into the New Blog Templates so it wasn't updated.

    However, I'm afraid that's a bit beyond my expertise so I'll need some help from our developers. I've asked them a question about the case and am awaiting their response. Please keep track of this ticket and we'll update you here as soon as we get to know more about the issue.

    Best regards,
    Adam

  • Ari
    • Recruit

    Hey diegpl

    Hope you are well today!

    We have default integration with Gravity Form, with allow users when they signup to filter through template category and select specific template. Here's the way to do it:



    Then when user fill the form they can filter through categories and select specific template:

    I found a bug in this integration and made a quick fix for it, you just need to replace this file: blogtemplates/blogtemplatesfiles/assets/js/toolbar.js with attached one make sure you unzipped the file first.

    ===

    If the default integration doesn't help you, can you please explain what you want clearly with detailed explanation? I'm sorry I couldn't understand above reply!

    Best Regards,
    Ari

  • diegpl
    • Syntax Hero

    Hi man, yes, I know about this default integration. But I would like a specific form bringing just the templates from a specific category, not a filter with all of them, because when the templates number is many it spoil the page loading performance. And I would like to show specific templates for specific pages as well, not just the possibility to get what you want through a filter, because users want to see just their niche when they load the page expecting see the templates that are really related to them, not a filter with many different areas...
    Did you understand? I know maybe you can not build that for me, but I would expect a little help showing the way to build the code by myself.

    Thank you very much! :wink:

  • diegpl
    • Syntax Hero

    Thank you a lot man, that is just awesome! You just got a huge fan of your work! :smiley:
    But I also need to be able to get it through the regular way, how can I get that as well? Because the default way will be visible at the home page, and the niche templates in their specific internal pages.

    Thank you very much! :wink:

  • diegpl
    • Syntax Hero

    Hi, really thank you for all your effort :slight_smile:
    But it did not work. Just as the original hook https://premium.wpmudev.org/forums/topic/select-a-specific-new-blog-template-using-gravity-forms#post-1206937 the code changes the GF User Registration feed NBT integration, but does not bring my choice to the front page, even when I check just the "Display Templates Selector" option and let "Template Categories" unchanged, with "select template" value. I have regular GF NBT integrations and esites.pro home. However, esites.pro/medico/ is not working since it was created and save with the hook up. Have you tested this hook on your installation? Did it work for you?

    Thank you very much! :wink:

  • Ari
    • Recruit

    Hey diegpl

    Hope you are well today!

    So custom integration is working, but the default one is not.
    Well, we have a bug in the default integration I said in my first reply: https://premium.wpmudev.org/forums/topic/domain-mapping-nbt-gravity-form-integration-hook-to-show-specific-template-is-not-working#post-1369962
    Where I have suggested to replace blogtemplates/blogtemplatesfiles/assets/js/toolbar.js file with the attached one.

    I'm not sure if you already did this! if not can you replace that file please?

    Also clear the plugin cache if you use any caching plugin and browser cache too as well, so browser doesn't cache the previous file.

    After all of above steps, if you still have this issue, please send me the login and FTP details of your site through our secure contact from: https://premium.wpmudev.org/contact/#i-have-a-different-question, so I can debug the issue.

    Please use the below template:

    Subject: "Attn: Ari"
    - WordPress admin (login url/username/password)
    - FTP credentials (host/username/password)
    - cPanel/Plesk credentials (host/username/password)
    - link back to this thread for reference
    - any other relevant urls

    Please keep in mind the subject line as ensures that it gets assigned to me.

    Have a great day!
    Warm Regards,
    Ari

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.