Grab Your Free 17-Point WordPress Pre-Launch PDF Checklist:
Download our exclusive 10-Point WP Hardening Checklist:

Adding Contact Form 7 Hidden Fields With Dynamic Data | WP Learning Lab

Adding hidden fields with dynamic contact to contact form 7 is easy when you install the contact form 7 modules plugin. If you don’t install that plugin you will need to create the functionality using Javascript and CSS.

The first thing we have to do is install the Contact Form 7 Modules plugin.

To install this plugin please log into your WordPress dashboard, hover over Plugins and then click on Add New.

On the next page type “Contact Form 7 Modules” into the search bar. The plugin we want should be the first one in the top left.

Click on the Install Now button and then click Activate after it’s installed.

Now go to your Contact Form 7 editor (click on the Contact menu item on the side menu, then click Edit below the form you want to add the hidden field to).

Inside the editor you will see a button labelled “hidden”. If you click inside the editor where your form code exists and then click on the “hidden” button a dialog box will open up.

Fill in the details and you have your hidden field.

I recommend you use a descriptive name for the Name field so that you know what the hidden field is for.

Then in the Value field you can enter a shortcode for dynamic content. Some of the available short codes and what they do are listed there and the rest are on this page (

I’ve compiled them all below, so you can read them right in the description.

– post_title – Inserts the title of the post/page
– post_category – The categories of the post or page
– post_url – The URL of the post or page
– post_author – The author of the post or page
– custom_field-[Name] – The value of a post or page’s custom field. If you had a custom field “Foo”, you would use the following as the hidden field value: custom_field-Foo

The following values will be replaced if an user is logged in:

– user_name: User Login
– user_id: User ID
– user_email: User Email Address
– user_display_name: Display Name (Generally the first and last name of the user)
– user_url: User Website

And you can also use it for user custom meta data using the format of user-{field}:

– user-aim: AIM
– user-jabber: Jabber / Google Talk
– user-description: User Bio

You can also use a filter: hook into the wpcf7_hidden_field_value filter to modify the value of the hidden field using add_filter(). If you know the ID of the input, you can also use the wpcf7_hidden_field_value_[#ID] filter.

There are lots of options for adding dynamic content to your hidden fields.

If the content you want to add is different that what the shortcodes provide then you will have to create a Javascript/jQuery and CSS solution.

Using those technologies what you can insert into hidden fields on a form is only limited by your imagination.

Don’t forget, after you add the hidden fields to the form, you have to add them to the mail tab as well. Otherwise the information won’t be sent to in the email that the form generates.

If you want to know more about customizing the email sent in the mail tab check out this tutorial:

I hope this information helps you! If you have any questions leave a comment below or ping me @WPLearningLab on Twitter.

————–

If you want more excellent WordPress information check out our website where we post WordPress tutorials daily.

Connect with us:

WP Learning Lab Channel:

Facebook:

Twitter:

Google Plus:

Pinterest:

Adding Contact Form 7 Hidden Fields With Dynamic Data | Contact Form 7 Tutorials Part 6
Adding Contact Form 7 Hidden Fields With Dynamic Data | Contact Form 7 Tutorials Part 6
Adding Contact Form 7 Hidden Fields With Dynamic Data | Contact Form 7 Tutorials Part 6
Adding Contact Form 7 Hidden Fields With Dynamic Data | Contact Form 7 Tutorials Part 6

Adding Contact Form 7 Hidden Fields With Dynamic Data | Contact Form 7 Tutorials Part 6