This Q&A walks through setting up a hidden field in Gravity Forms to pick up values from URL parameters. You’ll see how to enable dynamic population and test with query strings. A sample PHP filter snippet is included for full control.
Do you know Gravity Forms well?
Gravity Forms is a widely used WordPress plugin that lets you build forms—from simple contact forms to advanced surveys—using a visual interface without writing code.
If you need a directory-style display, check out the Gravity Forms Directory addon, which provides a shortcode-based approach, search capabilities, user editing of listings, and an approval process.
Anything specific you’d like to dive into with Gravity Forms?
So I wanted to ask if it's possible to fill in automatically a hidden field in Gravity Forms based on parameters in the URL.
Yes, you can have a hidden field pick up values from URL parameters. Here’s one way to set it up:
utm_campaign).Create a URL like:
https://yourwebsite.com/your-page/?utm_campaign=summer-sale
That hidden field will then be filled with summer-sale.
If you’d like full control over how parameters are handled, add this snippet to your theme’s functions.php:
add_filter('gform_field_value_your_parameter_name', 'populate_hidden_field');
function populate_hidden_field($value) {
if (isset($_GET['your_parameter_name'])) {
return sanitize_text_field($_GET['your_parameter_name']);
}
return $value;
}
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!