In this tutorial we’ll cover something quite useful – what Gravity Forms hook should we use to send our collected values to the external form with redirect.
Say we have several Gravity Forms forms, each one of them having different set of fields. We want to collect the submitted values and redirect the user with the prefilled values, using GET parameter. Our API will then handle these form and either submit the form, or ask the user to complete the submission.
If the API is on an external domain we have to whitelist it first, let’s use the following hook:
If we haven’t used it, then we’d simply be redirected to the wp-admin part of the site. This is quite good practice actually, as we are in the control of the redirect. This both makes sure that we avoid accidental redirects and send the user where intended. In case the redirect was variable based and our site hijacked – say someone wanted to collect our leads and would spoof the URL, the submittees would not hit the wrong site. This also makes sure that noone accidentally submits a wrong form, after hitting a similar site which sole purpose is to steal the leads.
For the purpose of this tutorial I assume that we want to have the whole data collected and a full Gravity Forms entry created.
Knowing that we need to hook into gravity forms confirmation hook:
Latest posts by Rafał Gicgier (see all)
- Remote work – pros and cons - 13 May 2019
- OptiPic.io – How and why to optimize the image on the site? - 8 April 2019
- Guest post at WP doin! - 26 March 2019