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.

Redirect if duplicate entry on AJAX submitted form

  1. I'm attempting to redirect a form if there is a duplicate email entry to a separate page. I'm actively testing on this page but the form lives elsewhere as part of a "game" on the site - http://www.readysetrecyclecontest.org/test/

    I've tried using gform_duplicate_message, gform_validation, gform_pre_submission hooks but implementing a PHP redirect only seems to work for forms that aren't submitted via AJAX. When I test using:

    header('Location: http://www.readysetrecyclecontest.org/duplicate-entry');

    in any of the hooks I mentioned the form doesn't submit it just hangs and nothing happens. I've tested using the admin preview and it works fine, but I need the form to submit via AJAX for other reasons so I'm trying to work out a solution to this redirect issue.

    Any help is greatly appreciated, thank you!

    Posted 12 years ago on Monday December 3, 2012 | Permalink
  2. I think you could use the gform_post_render hook to load your JavaScript on the page after a validation error (you'd have to test for that, so the code does not run every time the form is rendered ) http://www.gravityhelp.com/documentation/page/Gform_post_render

    The script you add could be something simple like this:

    [js]
    <script type="text/javascript">
      window.location.replace("http://www.readysetrecyclecontest.org/duplicate-entry/");
    </script>
    Posted 12 years ago on Monday December 3, 2012 | Permalink
  3. Ah okay, good idea, thank you for the suggestion, I'll try this out!

    Posted 12 years ago on Monday December 3, 2012 | Permalink
  4. Please let us know if that works. If not, we can try to come up with something else.

    Posted 12 years ago on Monday December 3, 2012 | Permalink