How to Preserve the Query Strings in the URL on Form Submit


Do you want to preserve the query strings in the URL when your form submits? If you’re using the Dynamic Field Choices but want to preserve those URLs when the form submits, a simple PHP snippet is all that is needed to accomplish this. In this article, we’ll show you the PHP needed to preserve these strings when the form submits.

By default, when you’ve created your form to accept Dynamic Field Choices and query strings, once the form submits, this URL is replaced with the default page URL.


The code shown below will retain the URL, including the query strings and dynamic choices, when the form submits.

Simply copy and paste this snippet to your site.

For help in adding snippets to your site, please review this tutorial.

 * Preserve the query strings in the URL on form submit.
 * @link

function wpf_dev_process_redirect_url() {

	global $wp;

	$current_url = home_url( add_query_arg( array( $_GET), $wp->request ) );

	return $current_url;


add_filter( 'wpforms_process_redirect_url', 'wpf_dev_process_redirect_url' );

This snippet will make sure when the form submits and the page refreshes, the URL will not change.

With the PHP snippet above the query string will remain in the URL on the form submission

And that’s all you need to preserve the query strings in the URL after submission. Would you like to learn how to use the User Registration addon to automatically log your users in once the registration is complete? Take a look at our tutorial on How to Automatically Log in Users After Registration.

Filter reference: wpforms_process_redirect_url