Contact form 7 dynamic values

A little known fact about Contact Form 7 is that you can dynamically set the values of your form input fields. Every Contact Form 7 input field supports the data-attribute. An advanced example on how to use this attribute can be found here: Dynamically populate a Contact Form 7 dropdown list (or any other input field)

The example above requires you to add a little bit of code to your theme, but there is also a much more straightforward way to set a value based on the querystring you add to your page URL with default:get.

Just add default:get to all fields you would like to set dynamically, like this:

<label>Your name [text* your-name default:get]</label>
<label>Your email [email* your-email default:get]</label>
<label>Subject [text* your-subject default:get]</label>
<label>Your message (optional) [textarea your-message default:get]</label>
[submit "Submit"]

Now you can point people to this form with their information pre-filled in the URL, like this:

https://bdwm.be/contact-form-7-dynamic-values/?your-name=John+Doe&your-email=john@example.com&your-subject=This+is+my+subject&your-message=My+message

If you clicked the link above, you should now see that the fields in the form are pre-filled. You can also change the values in the URL and reload the page to see the fields update.