WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7 Modules
[resolved] Not getting hiden field value (2 posts)

  1. anandonnet
    Member
    Posted 2 years ago #

    I am using a URL like this

    http://www.mytestsite.com/sample-form/?category=12345

    I would like to receive the value 12345 against category variable in my email.

    I used syntact like this: [hidden hidden-271 "custom_field-category"] on the form and Category:[hidden-271] inside message body,

    I dont get a value, could you tell me how to get default value for a custom field thru query string or other modes.

    Thanks,
    Anand

    http://wordpress.org/extend/plugins/contact-form-7-modules/

  2. Zack Katz
    Member
    Plugin Author

    Posted 1 year ago #

    Use the this tag inside the form: [hidden hidden-271 id:categoryrequest] and [hidden-271] inside the message body.

    And then you can add the following code to your theme's functions.php file:

    add_filter('wpcf7_hidden_field_value_categoryrequest', 'wpcf7_hidden_field_add_query_arg');
    function wpcf7_hidden_field_add_query_arg($value = '') {
    	if(isset($_GET['category'])) {
    		return $_GET['category'];
    	}
    	return $value;
    }

    This will achieve what you're looking to do.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.