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:
We’ve just released Widget Base Class to facilitate WordPress widget creation!
Widget Base Class is a PHP class which facilitates widget creation, by faster creation, sanitization, validation and updates of Widget fields. Such an approach lets one set up widgets much faster, without code repetitions and care for messy data validation.
Thanks to that we can get rid of the update method completely and stop worrying about the form validation itself.
The widget does all of the data validation on its own. However we have to define the fields we want to use, so that our base class would have an idea on what kind of fields we’d like to use.
The class itself can be found on github.[biginfobox textcolor=”#ffffff” title=”Have you checked our other free software yet?” href=”https://wp-doin.com/portfolio/#plugin” button_title=”Free Plugins” target=”_blank”]There’s a Base Theme and a Widget Wrapper Class to use! [/biginfobox]
WordPress itself is so powerful, that it’s actually quite slow. The number of functions, database calls and the enormous amount of code makes it obvious why does it happen.
Some people say that due to that WordPress itself is “crap”. I honestly do get their point. Some programmers belive that it’s a be-all solution, suitable for everything forcing default WP installation everywhere making it use considerable amount of server resources. WordPress core code is also very inconsistent, there are some functions prefixed with wp_ there are some non-prefixed. There are global variables all over the place. Default PHP functionality can be used instead of “wise” WP functions and so on. Lastly WordPress is problematic with design patterns. Especially considering OOP. Method visibility failes hard with WordPress actions and filters.
On the other hand WordPress is very simple to learn and use. It’s most probably the perfect place for a to-be-programmers starter. Additionally the enormous community and amount of plugins extends its power even more.
We believe that its a matter of wise judgment. Certainly its absolutely idiotic idea to overcomplicate stuff. There’s no need to use WordPress everywhere.
We are not going to judge anybody on using or not using it. It’s solely up to you and your judgment, profession or skills. Just don’t blame people for trying to achieve something – Rome wasn’t built in a day. And you haven’t become a source of programming patterns wisdom either.
Given the above we’re going to give one couple of tips on how have we optimized our WordPress installation following Google Page Speed Insight and several WordPress plugins.
The biggest con of using these plugins is the fact, that with all the settings enabled they will do the opposite from expected. They will most likely render the site useless.
W3TC relies on several PHP libraries which might not be supported on one’s server.
Asynchronously loading resources doesn’t work all the time. With script and style dependencies some functionality may be disabled. (Like missing jQuery call called by the Gravity Forms)
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.