Contact Form 7 Dynamic Text Extension
[resolved] Setting default value for CF7_GET (3 posts)

  1. huskypup
    Posted 3 years ago #

    I have a form that uses CF7_GET to pass email recipient address via a link within the content. It all works well apart from when the form is accessed via the page menu, due to it being a direct link to the page without variables being passed through the URL.

    Is there a way to set a default recipient? The form short code I'm using is

    [dynamichidden email-recipient "CF7_GET key='email_recipient' obfuscate='on'"]


  2. sevenspark
    Plugin Author

    Posted 3 years ago #

    To do that I think you would want to write a custom version of the CF7_get shortcode and set a default if no value is set.

  3. huskypup
    Posted 3 years ago #

    Thanks for replying, it pointed me in the right direction.

    I'm afraid my PHP skills are not very good, but I managed to cobble this together if anyone is interested.

    This goes into your functions.php

    function cf7_get_feedback_form_sc($atts){
    		'key' => '',
    		'default' => 'email@address.com'
    	), $atts));
    	if(isset($_GET[$key]) and !empty($_GET[$key])) {
    		return $_GET[$key];
    	} else {
    		return $default;
    add_shortcode('CF7_GET_feedback_form', 'cf7_get_feedback_form_sc');

    I then use this as the shortcode used in Contact Form 7

    [dynamichidden email-recipient id:email-recipient "CF7_GET_feedback_form key='email_recipient'"]

    Hopefully it's okay, but I'm happy for feedback.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7 Dynamic Text Extension
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic