If you’re using key/value arguments in the query string, you can access them using CF7_GET shortcode and the key attribute. The value of the key attribute is the name of the key in your query string that you want the value for. In PHP code, this is accessing the $_GET variable.
[CF7_GET key="<insert key value here>"]
Example
If there was a form located on https://aurisecreative.com?foo=bar and I wanted to dynamically populate a form field with the value of the foo parameter in the query string, the value of my dynamic field would use this as its value:
CF7_GET key='foo'
And the form tag would look like this:
[dynamictext inputname "CF7_GET key='foo'"]
Cache Compatibility
If the HTML of your webpage is being cached, preventing the server from processing the shortcode before displaying the form, then you can enable cache compatibility mode for this form tag.
However, this built-in shortcode is unique in that it does not make an AJAX request. Instead, it simply uses JavaScript to pull the value from the URL’s query string at the provided key.
Demo
You can see this in action! Simply click this link to reload the page with the query parameters foo and hello or type in your own!
View Source Code
View the current source code for the server-side shortcode or for the client-side JavaScript function.
Contact Form 7 Native Functionality
In a later version of Contact Form 7, the default:{source} option was introduced for form tags. This native feature in Contact Form 7 may make it seem like our DTX shortcode is redundant, but not quite. In order for their method to work, the name of your form tag needs to match that of the key from your source. Using the same example from above, the form tag would look like this:
[text foo default:get]
While we’re glad to see this functionality make it into the core of Contact Form 7, DTX offers the flexibility for mapping keys to form fields with different names, adding security through obfuscating the value, and compatibility with caching plugins. Of course, we like our method better especially for pulling in values with strange or long keys.