PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Conditional Redirects, preserving posted data

  1. Hi,

    Have searched extensively and haven't found the answer to this one.

    I am using four GFs in conjunction: the first essentially selects which of the remaining three the user is then presented with.

    The first page must be a separate form because the overall data capture process is quite long and complex and the requirement is to capture simple baseline information using the first form even if the longer secondary forms are then abandoned.

    The secondary forms must be able to retrieve the data posted from the first form.

    I have checked out this solution: but can't work out a way to do this redirect whilst (securely) preserving the posted data.

    Is there ANY way to filter gform_post_submission (or something else) to make the redirection dependent on a posted value?

    I think the GF team has this functionality in the pipeline - any chance of some copy/pastery or will it just not work with the current releases?

    Thanks :)

    Posted 9 years ago on Monday November 29, 2010 | Permalink
  2. You can use the Confirmation Redirect functionality to set the confirmation for Form 1 to redirect to the page containing Form 2 and pass data from Form 1 via the query string to pre-populate fields in Form 2.

    You would have to setup Form 1 so that the confirmation redirect goes to the page that contains Form 2 using the URL Redirect. You would then use the querystring builder for the redirect to pass the field values via the querystring.

    On form 2 you would setup each of the fields you want to pre-populate via the querystring so that they can be populated dynamically and give them a parameter name that is then used in the querystring (ex. parameter name email would then be used to pass in the querystring).

    Gravity Forms does not currently do conditional redirects for the form confirmation. It is a feature we plan on adding in the future, however currently it requires custom work to do. You would create a PHP page that handles the redirect, and redirect your form to this PHP page and then write your own custom redirect.

    Posted 9 years ago on Monday November 29, 2010 | Permalink
  3. Hi Carl,

    Thanks so much - awesome support.

    I got this far in my research. My problem challenge is that I need to post onto Form 2a, Form 2b or Form 2c depending the answers in Form 1.

    I know you say that's not possible without custom coding. I understood that to be the case and am pleased it's in the pipeline.

    I guess the solution might be to develop a custom function in WordPress that calls a different Form 2x depending on what the post values are.

    I'll try to post back here with a solution if I get it working. Any other ideas anyone?

    Posted 9 years ago on Monday November 29, 2010 | Permalink
  4. er...if you are sending the querystring through the header anyway...the conditional fields could always set up in a page that contains the form(s)

    $Sex == $_POST['gender']
    if (strtolowe($Sex) == strtolower('female')){ echo "this form";}
    elseif (strtolowe($Sex) == strtolower('male'){echo "this one";}
    else {"default form";}

    you can pretty much print whatever form you want based on the variables and conditionals you set up on a single page.

    Posted 9 years ago on Monday November 29, 2010 | Permalink
  5. You can create a custom PHP page that redirects based on querystring values being sent to it, and then passes those querystring values again to the redirect page. Then set Form 1 to redirect to your custom PHP page, passing the form field values in the querystring, your custom PHP page determines where it should go and redirects to the appropriate page... passing the querystring values again.

    Posted 9 years ago on Monday November 29, 2010 | Permalink
  6. Hi @Carl, @urmedia,

    Thanks both.

    @urmedia - I think that's the route I'll go down.

    @Carl - in case I need to switch method, is there any chance you could provide an example of how to rePOST the querystring on a redirect? I spent a long time looking (probably using the wrong search phrases) and couldn't find a secure way to do it without specifying each possible variable...

    Again, thanks.

    Posted 9 years ago on Tuesday November 30, 2010 | Permalink
  7. Here is example code to redirect to a page and grab the full querystring from the existing page and pass it to the page you are redirecting to.

    $redirect_to_url = "" . $_SERVER["QUERY_STRING"];

    Posted 9 years ago on Tuesday November 30, 2010 | Permalink
  8. Thanks Carl - much obliged :)

    Posted 9 years ago on Tuesday November 30, 2010 | Permalink

This topic has been resolved and has been closed to new replies.