You may wish to restrict access to a post to only those who have completed a data capture form. A practical example can be found on the SMILE website. We publish roundups from our webinars which include a recording, slides, links, questions etc. But we require that you be signed up to our mailing list in order to access it.
This article will show you how to do similar.
- You must be able to access “Custom fields” in the edit screen
- You must have the Gravity Forms and Gravity Forms Submit to Access enabled (both are available for HappyPress subscribers at no additional cost)
- You must have the Redirection plugin enabled (available for HappyPress subscribers at no additinoal cost)
- Create a form that you want users to fill out in order to access your post. Make a note of the form ID. You can find this in the list of forms.
- Create and publish a page with your form added in the main body. We will redirect users to this page if they have not filled out the form before. Make a note of the URL to this page.
- Add the following custom fields to the post you wish to restrict…
Value: Set this to the form ID that you require the user to have completed in order to access this post. If you require multiple forms, simply add a comma separated list of values (Example:
This sends the post data via AJAX, in order to avoid the cache. Note: this does not always work – especially on HappyPress. There is an optional tip at the end of this list which will ensure you bypass the cache.
Value: The URL to the page where your form is hosted
Don’t do this, as it damages your RSS feed!
- OPTIONAL (recommended for HappyPress subscribers): Add a redirect under
Tools > Redirectionfor the post you have restricted access to.
- Source URL: The URL to the post you wish to access
- Query Parameters:
Exact match in any order
- Target URL: The URL to the post you wish to access, appended by
- In truth, any query parameter here is fine. We like this one because its semantically obvious for newcomers to understand. But all this is doing is hitting a rule in HappyPress that means the page will not be server-side cached. As a result, this technique is not great for posts that may have very high numbers of concurrent users.
Now your users will be redirected to the form if they have not previously filled it out. When they do, a cookie will be added to their device so that they do not get redirected again in the future. They will then be able to access the post.
For more options in the Gravity Forms Submit to Access plugin, please visit the Gravity Perks website.