Quantcast
Channel: Tutorials Archives | Gravity Wiz
Viewing all articles
Browse latest Browse all 122

Redirect to Referrer URL after Gravity Form Submission

$
0
0

This tutorial demonstrates a simple, code-less method for redirecting users back to the URL they came from before accessing the form. This is useful in situations where you may require registration or just to collect some information to view a page. After registration, you can easily redirect the user back to the page they were originally viewing.

This is especially useful if you’re using Gravity Forms to register a user via the User Registration add-on. The user attempts to access a protected page. They are directed to a separate page to register (via a Gravity Form). The registration form redirects them back to the now-unlocked page.
To streamline the process even further use the GP Auto Login plugin so the user arrives at the previous page already logged in and ready to view the protected content.

Steps

  1. Capture the Referrer URL
  2. Setup a “Redirect” Confirmation for Your Form
This technique requires Gravity Forms v1.9.1 or greater.

1. Capture the Referrer URL

  1. Add a hidden field to your Gravity Form.
  2. Add {referer} to the Default Value for the hidden field.
  3. Save your form.
redirect-to-referrer-url-field

You may be wondering if Gravity Forms has a {referer} merge tag, why don’t we just use that in the confirmation redirect?

The issue is that if you submit the form, the page URL that the form is submitted from becomes the referrer. We must stash the original referrer to the field.

2. Setup a “Redirect” Confirmation for Your Form

  1. Go the Confirmations page.
  2. Edit the default confirmation – or – add a new confirmation.
  3. Select “Redirect” as the “Confirmation Type”.
  4. Add the merge tag of the field we created in step #1.
  5. Save your confirmation.
redirect-to-referrer-url-confirmation

All done!

How’d we do?

If you found this tutorial helpful, let us know. We’d love to hear any cool use-cases where you’ve put this technique into action!


Viewing all articles
Browse latest Browse all 122

Trending Articles