Redirecting with form data

This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.

To redirect with form data you will need to add a PHP function to grab the data you need and build the redirect URL.

Step 1

Make sure that in Settings → General → Successful submit options the option On successful submit is set to Redirect to another page. It doesn’t matter what option you choose for the Redirect to option, we will set the URL in the PHP function in Step 2.

Step 2

In the example below we will add the Name and Email of the form submitter to the redirect URL, using the WordPress function add_query_arg. Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

1
2
3
456
7
8
9
1011
12
13
14
function my_form_redirect($url, $form)
{
    $data = array(
        'name' => $form->getValue('iphorm_1_1'),        'email' => $form->getValue('iphorm_1_2'),    );
 
    $data = array_map('rawurlencode', $data);
 
    $url = add_query_arg($data, 'http://www.example.com/thank-you-page'); 
    return $url;
}
add_action('iphorm_success_redirect_url_1', 'my_form_redirect', 10, 2);
function my_form_redirect($url, $form)
{
    $data = array(
        'name' => $form->getValue('iphorm_1_1'),
        'email' => $form->getValue('iphorm_1_2'),
    );

    $data = array_map('rawurlencode', $data);

    $url = add_query_arg($data, 'http://www.example.com/thank-you-page');

    return $url;
}
add_action('iphorm_success_redirect_url_1', 'my_form_redirect', 10, 2);

Modify the above lines to suit the form setup.

  • On line 4, change iphorm_1_1 to the unique element ID of the “Name” element
  • On line 5, change iphorm_1_2 to the unique element ID of the “Email” element
  • On line 10, change http://www.example.com/thank-you-page to the redirect URL
  • On line 14, change the number 1 to the form ID

To add more form data to the URL, simply add more lines to the array (between lines 3-6).

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy