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.

Use Shortcode to assign a Redirect/Confirmation page

  1. I saw this has been requested before:

    http://www.gravityhelp.com/forums/topic/can-i-give-the-redirect-page-in-the-shortcode

    Basically, my client has one lead form that they have to duplicate every time just to change the redirect/confirmation page. This is naturally causing a lot of trouble just for this one change. Can the shortcode be used to assign a confirmation page?

    Posted 11 years ago on Tuesday November 27, 2012 | Permalink
  2. Please explain how you would like to use this. Maybe we can come up with a solution. Are you saying you would like the shortcode you embed in your page to support the inclusion of a URL for the confirmation redirect?

    If that is the case, you could always add a hidden field to your form, allow it to be populated dynamically, then populate that field in the shortcode using the method found here:
    http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population#Shortcode

    Now that you have the URL or at least the changed part of the URL ( you could probably skip the http and the domain name, and just put that together later ) you could change the confirmation redirect to use the value in this field (be sure to include a default value for this field so that there is always a redirect URL even when the value is not pre-populated.) You could change the confirmation URL with the gform_confirmation filter.

    http://www.gravityhelp.com/documentation/page/Gform_confirmation

    A little bit of code up front would make this much easier for your client, I believe.

    Posted 11 years ago on Tuesday November 27, 2012 | Permalink
  3. Essentially, the client has 12 landing pages (and growing) running the same form with the same fields, except each form goes to a different redirect page once the form is completed and submitted. As it stands, they need to duplicate this form every time they want to embed the form on a page but only want to change the destination of the confirmation page.

    You asked:

    "Are you saying you would like the shortcode you embed in your page to support the inclusion of a URL for the confirmation redirect?"

    Yes, that is exactly it. :)

    Posted 11 years ago on Tuesday November 27, 2012 | Permalink
  4. So I set up a field with the value of 'redirect' and can populate it with the shortcode. My next question is how do I detect the redirect field and then drop that value into the confirmation filter?

    I imagine it would look something like this, but I do not know how to establish the value of $redirect:

    add_filter("gform_confirmation", "custom_confirmation", 10, 4);
    function custom_confirmation($confirmation, $form, $lead, $ajax){
    
     $confirmation = array("redirect" =>$redirect);
    return $confirmation;
    }
    Posted 11 years ago on Friday November 30, 2012 | Permalink
  5. You will get $redirect as one of you form field values. What field number is it in your form? If it were field 8, for example, you would do this:

    [php]
    $redirect = $entry[8];

    If that field holds the full URL, that is all you will need to do. If you are just using a slug in the shortcode (which may be easier for your administrators), you might have to built your URL, like this

    [php]
    $redirect = 'http://www.example.com/' . $entry[8];

    Let us know what value your shortcode will hold for 'redirect' and let us know what field number it is, if you still need help. Thank you.

    Posted 11 years ago on Saturday December 1, 2012 | Permalink