• Resolved formless

    (@formless)


    Thank you for your great plugin.

    This time, I wanna display a form dynamically depending on url parameter in a certain page with a slug as ‘formpage’.
    In particular, a page ‘(wp_root)/formpage/?form_key=NNN’ needs to show [mwform_formkey key=”NNN”].

    In some old questions, you said that a template file needs to include ‘[mwform_formkey key=”NNN”]’ to make the shortcode work.
    But in my case, NNN is dynamic, so it is seemingly impossible.

    Is there any way to solve this situation? (like using hook or so)

    Thanks in advance.

    Regards.

Viewing 1 replies (of 1 total)
  • Thread Starter formless

    (@formless)

    Hi Mr.Kitajima

    I solved my issue like below.

    
    add_filter('template_include',
    	function ($template) {
    		if( is_page( 'some-specific-page-slug' ) && isset( $_GET['form_key'] ) && (int)$_GET['form_key'] > 0 ){
    			global $post;
    			$post->post_content = '[mwform_formkey key="' . (int)$_GET['form_key'] . '"]';
    		}
    		return $template;
    	}
    );

    Seemingly it is woking OK so far.
    Do you think it will cause other problem?

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode ‘mwform_formkey’ in template file does not work dynamically’ is closed to new replies.