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.

Pre-submission filter - redirect not working after 1.7.2 upgrade

  1. Hi,

    I've been using the gform_pre_submission_filter to programatically alter my redirects (I got tired of having to manually alter the URL after multiple location changes, so I have a function that replaces the old directory with the new one, among other things).

    As of the latest update, my function is still being called, but the url does not appear to be setting.

    I can't link to the site as it is a confidential project, but the gist of the function is:

    add_filter("gform_pre_submission_filter", "custom_confirmation", 10, 4);
    
    function custom_confirmation($form){
    $redir = $form["confirmation"]["url"];
    $redir_new = str_replace("old-domain.com","new-domain.com",$redir);
    $form["confirmation"]["url"] = $redir_new;
    return $form;
    }

    I have debugged the function itself and it is being called and properly constructing the new URL. But the URL manually added in the form is what is now being called, wrecking most of the form functionality on my prototype.

    I imagine this has to do with the new ability to configure conditional redirects, but debugging the form object isn't revealing how. Can you please let me know if I need to change filters etc?

    Thanks,
    Katharine

    Posted 10 years ago on Monday May 6, 2013 | Permalink
  2. I have found a very clunky workaround, which is to use the gform_confirmation filter. It passes in $confirmation as the first parameter, which contains a javascript string:

    <script type="text/javascript"> function gformRedirect(){document.location.href='http://my-url.com?parm1=value&parm2=value';}</script>

    So I can do a replace on the URL bit and pass back the altered javascript. It's really ugly though, and I imagine susceptible to break in future updates - so any advice on a cleaner way to do this is welcome.
    Thanks,
    Katharine

    Posted 10 years ago on Monday May 6, 2013 | Permalink
  3. Have you heard anything? I'm working on this same thing with a few exceptions:
    I am trying to use gform_validation to allow targeting submitted field value (that I want to make into the page slug) with a css class.
    I am trying to construct the url using site_url() with the value of a field on the submitted form being appended as the page slug.
    Finally trying to use gform_confirmation to take the created url and present it to the user submitting the form. So they can get to the desired 2nd form.

    Posted 10 years ago on Friday May 31, 2013 | Permalink