Contact Form 7 is a great plugin to add forms to your site, but these forms contain static inputs and sometimes we require to add inputs with dynamic values like a post ID or PHP variables like GET and POST.
This is very easy to do with the plugin Contact Form 7 Dynamic Text Extension.
This plugin adds two additional tag types to the Contact Form 7 plugin, these two types are Dynamic Text field and Dynamic Hidden field, the dynamic value for a scpecif input is generated throught a shortcode.
The plugin has it’s own shortcodes integrated, but you can create your own.
Let me put a very simple example:
Lets say you want to add a hidden input in your form which value should be the current post ID.
If you create your own shortcode it would look like this:
function cf7_add_post_id(){ global $post; return $post->ID; } add_shortcode('CF7_ADD_POST_ID', 'cf7_add_post_id'); |
And the dynamic field in your form setup would look like this:
[dynamictext my-filed-name "CF7_ADD_POST_ID"]
The other way would be to use the plugin’s shortcodes.
In this case we want to have the current post ID so you would only have to add your dynamic field in the form setup like this:
[dynamictext my-filed-name "CF7_get_post_var key='ID'"]
The plugin has shortcodes for GET, POST, blog info, post info, current URL, custom fields, current user info, referrer URL.
You have all the details in the plugin’s page on wordpress.org
s
Hi,
my form is build on 4 tabs with cf7 skin multi and in the last tab I would like to summurize the previous input using the dynamic text extension. Have you any idea about how i can get previous input and insert them on the last tab as dynamic text?
Really Thank You
Luca
dfdr
Hi If you are looking dynamic number generation into contact form 7 this WordPress guide will help you.
https://www.banna360.com/contact-from7-dynamic-number-generation/
Hi,
How to add dynamic input text field after select dropdown value in contact form 7
How would I go about adding the following in:
It’s a cookie, but hidden – to get the URL.
This was what I was trying to show in my previous comment:
https://gyazo.com/09b5079bb36d7f61cd78ede625e71410
goddamn thank you!!!! your simply example has helped me no end – i have been trying to get this to work for a number of days with no help from the community. well done.
I’m really enjoying the theme/design of your blog. Do you ever run into any browser compatibility issues? A small number of my blog audience have complained about my website not working correctly in Explorer but looks great in Firefox. Do you have any advice to help fix this problem?
bestdayonraiditem.tumblr.com https://bestdayonraiditem.tumblr.com/
m,l;ljkbhjj
how do I get that information into the mail that I receive?
Hello,
Can i using above example in same as contact form 7 hidden field.
Thanks.
Hi,
I have setup and woocommerce and have displayed the product enquiry button on the cart page (the products i have got here are from “add to cart” button). The problem i am having is to get the dynamic product name in to the ContactForm7 form.
can you please guide me if there is a way for having the dynamically included product name in the contact form 7.
Thanks.
Hi
Thanks for your nice post, I am search a way on how to display visual composer advance button attributes in Contact form 7 field, I installed Dynamic text contact form 7 but I cant find the way actually.
would you please have a way to fix my solve.
thanks
Could you also give an example of how to do this with an advanced custom field (ACF) instead of post ID?