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.

How to dynamically set redirect URL for Ajax-enabled form?

  1. Possibly related to this topic:? Confirmation filter + Ajax = stuck

    I'm trying to dynamically set the redirect url on my Ajax-enabled form - basically, its just a matter of adding field data to the query string, but it requires some server-side preprocessing so I can't just use the merge tags provided in the "Form Settings" dialog.

    I have a function hooked on gform_confirmation which adds the query string args I need to the $confirmation['redirect'] argument. However, it never gets called because the get_js_confirmation_redirect function is called before the gform_confirmation filters are applied.

    I've worked around this by setting my form with a confirmation message, and having the entire confirmation url applied by the filter. However, it would make sense to move the gform_confirmation filter above the function which performs the redirect for Ajax-enabled forms.

    Posted 12 years ago on Sunday March 4, 2012 | Permalink
  2. Actually, if I were making feature requests, I''d like to see two things:

    • Get rid of the client-side redirection in lines 949-952 of form-display.php -- its handled already in line 965, after the appropriate filters are applied, and that's a better place for it.
    • Add a (PHP) filter in the function get_js_redirect_confirmation() so that users can modify the javascript gformRedirect() function that gets output. (In my case, I have Google Analytics event tracking on all outgoing links on my site and would like to trigger an event before redirecting. I'd also like the ability to open the confirmation page in a new tab.)

    Thanks for all the work on the plugin so far.

    Posted 12 years ago on Sunday March 4, 2012 | Permalink