January 12, 2023: Added
cookie_expiration
parameter to allow configuring when the cookie that tracks submitted forms expires.November 23, 2021: Added
gfsa_has_access
filter for filtering whether the current viewer has access to a given post.March 2, 2021: Updated snippet to run as a Singleton plugin. Added
gw_submit_to_access()->has_submitted_form()
helper method.June 21, 2017: Improved support for automatically showing required form if no required message is specified.
March 2, 2017: Updated submitted forms cookie to be persistent by default. Added new "is_persistent" option to disable this.
March 1, 2017: Added support for "gwsa_requires_submission_redirect" option to allow automatically redirecting to a specific page if the user requires access.
March 23, 2016: Added support for requiring a form to be submitted before any page can be accessed. Added support for storing submitted forms in user meta.
March 3, 2015: Added support for shortcodes in "gwsa_requires_submission_message" custom field. Fixed issue where json_decode() did not return an array.
You have a post or page you’d like to protect but you don’t want to require the user to sign up for a user account and you just don’t need a full-blown membership system. All you want to do is collect a few details about the user for your mailing list or CRM.
This plugin provides an easy way to accomplish this. Any post-based content (that includes pages and custom post types) that support custom fields can be locked down. You set a few special custom fields and the Gravity Forms Submit to Access plugin takes care of the rest.
Getting Started
Check requirements
- Make sure you have Gravity Forms installed and activated.
- Already have a license? Download Latest Gravity Forms
- Need a license? Buy Gravity Forms
Install the plugin
- Click the “Download Code” button above and save the file to your Desktop.
- Drop the file into your WordPress plugins folder via FTP – or – zip the file up and upload it via WordPress plugin uploader.
Configure the plugin
- Read on for step-by-step instructions
Locking Down a Page
Navigate to the Edit screen for any post, page, or any custom post type.
Enable “Custom Fields via the Screen Options at the top of the page. There is a good chance they are already enabled.
Add a custom field named gwsa_require_submission with a value of
1
.Add a custom field named gwsa_form_ids and set the value to the ID of whichever form the user should submit to gain access to this page.
That’s it!
Custom Field Options
gwsa_require_submission (string) (required)
Add this custom field with a value of
1
to require a Gravity Form to be submitted to gain access. Set this value toper_page
to require the submission on the page itself.gwsa_form_ids (bool) (optional)
Add this custom field and set the value to the ID of the form which must be submitted to gain access to this page. If there are multiple forms that can be submitted to gain access, you may include them as a comma-delimited list (i.e.
1,2,3
). If any form can be submitted to gain access to this page, do not add this custom field option.gwsa_requires_submission_message (string) (optional)
Override the default message that is displayed when the user does not have access to view the content of this page.
Use the
{form}
custom merge tag to control where the required form is output alongside the requires submission message. This allows you to wrap the form and message in your own custom markup.gwsa_requires_submission_redirect (string) (optional)
Provide a URL to which the user will be redirected if they do not have access to view the content of this page.
Per Page Locking
By default, any pages locked by the same form submission will all be unlocked simultaneously. For example, let’s say you lock down two pages on your site, called Welcome New Members and House Rules, and you only want members of your site to be able to view those pages. You can use the same form to unlock both pages by inserting the same Form ID into the gwsa_form_ids field on both pages. When a user submits the form on either of the two pages, both pages are unlocked at the same time.
In some cases, you only want to unlock a page when a form is submitted on that page. In the case of the examples pages above, you might have a simple Terms of Service form that requires the user check a box indicating they have read the terms before they can view the content. If you set the gwsa_require_submission custom field value to per_page
instead of 1
, the page content is only unlocked when the user submits the form on that specific page.
Global Parameters
requires_submission_message (string) (optional)
Define the default message that is displayed if the user does not have access to the content. This value will be overridden if a post-specific message is set via the gwsa_requires_submission_message custom field option. Defaults to
'Oops! You do not have access to this page.'
.bypass_cache (bool) (optional)
Enabling this option will allow the script to bypass any page/cookie caching by fetching the post content via AJAX. Defaults to
false
.loading_message (array) (optional)
If bypass_cache is enabled, this option allows you to control the loading message which is visible while the post content is being fetched via AJAX.
is_persistent (bool) (optional)
The cookie that stores which forms have been submitted for the visitor is persistent by default. Set this to
false
to make the cookie session-based.enable_user_meta (bool) (optional)
Set this to
true
to save submitted forms in the user meta rather than a cookie. Only works for logged-in users.cookie_expiration (bool) (optional)
Set this to a timestamp (in the future) at which the cookie should expire. For example, to have the cookie expire each night at midnight, set the value to:
strtotime( 'midnight tomorrow' )
.
Any questions?
This is a bare bones plugin. It uses WordPress’ custom fields UI to handle setting the options and advanced configuration should happen in the plugin.
If this proves to be a popular resource, I’ll be happy to enhance it to be even easier to use.
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 47+ essential add-ons for Gravity Forms with support you can count on.
I think I know the answer but I was wondering if this plugin could only hide content coming from the_content or if I could get it to hide template parts as wekk?
Hi Joshua, it currently only supports hiding the_content. You can contact us via our support form so we can get more information about your use case if you have an Advanced or Pro license.
Hi All, great plugin. The process is working as expected in that my content is gated and only after submitting the form is it accessible. However, is the form supposed to display when using the “gwsa_requires_submission_message” field and the {form} merge tag? I only see my message and “{form}” on the frontend. Do I need an additional plugin or setting?
Yes, it should output the form. I confirmed it’s working for me with the following configuration: https://share.cleanshot.com/stfC6hzP
Followed the setup instructions; nothing works except for the page being correctly blocked. 1. Gravity forms submission doesn’t work. Throws an error for a functional form. 2. Incorrectly displays 3x of the same form. 3. Terrible styling of the block page with no obvious way to improve it.
Hi Brad,
Based on what you describe, the issue could be related to another code conflicting with the snippet. If you have an active Gravity Perks Advanced or Pro license, you can contact us via our support form.
Best,
Hi,
Is there a way to use this to password-protect the page?
Jennifer
Hi Jennifer,
No, this can’t be used to password-protect the page because it works with every form submission. You can use the default WordPress functionality to password-protect a page.
Best,
Hello,
First of all, thanks for the plugin. I am trying to lock the blog archives post page, but it does not seem to work. It only works on other pages. Is there a limitation on the archive page?
Hi Marcos,
Currently the plugin doesn’t support locking the blog Posts page. I’m going to log it as a feature request.
Hello,
So I added the custom fields to my page I want to protect with the appropriate values – using ACF, but when I load the page I want to protect – it does not take me to the gravity form they need to fill out to get access. It just does nothing. Acts like normal.. Is there some obivous thing I’m forgetting? Thanks!
Greg
Hi Greg,
As long as both the
gwsa_form_ids
andgwsa_require_submission
custom fields have the appropriate values on the page, it should work. Do note that if you have already submitted the form with your user, you’ll need to delete those entries and clear your session cookies in order to test.If all of those conditions are met and you’re still having trouble and you’re a Gravity Perks subscriber, drop us a line and we’ll be happy to dig into it.
Hmmm, I have those fields/values configured correctly… Is it because I chose value type as number that it’s not working? Maybe I should just leave it as text? I’m not a subscriber, but is it free to sign up? Thanks!!
A value type of number should still work. Can you verify that you installed the plugin?
Gravity Perks is a paid subscription, which gives you access to our 45+ GF Add-Ons.
Yes, I installed Gravity Forms Submit to Access Version 1.11 by Gravity Wiz. But I have to install Gravity Perks as well? Thanks,
Greg
Hi Greg,
You do not need the Gravity Perks plugin to use the Submit to Access plugin. However, support is only available to customers with a Gravity Perks license. If you have a license you can get in touch with us via our support form so we can assist you further.
Best,
Ok thank you.
Hi,
Using this with Elementor and Woocommerce – with the form on the checkout page (disclosure form) – when submitted the page refreshes and adds a “?” to the end of the url. The checkout does not load, says “you do not have permission to view this page” – when refreshed – page loads fine?
Hi Aaron,
Do you have the checkout page set as the confirmation page of the form? If not, please do that and check if it works for you but if this doesn’t work, then we’ll need to dig into this further. You can get in touch with us via our support form, if you have an active Gravity Perks license, so we can assist you further.
Best,
How can I create a form with gated content? (A downloadable) also want to integrate with sendgrid.
waiting for your response
Hi Aleem,
You can use the snippet in this tutorial to create the gated content to a page with the link to download what they want. If this snippet wouldn’t work for you and you have a specific use case, you can get in touch with us via our support form, if you have an active Gravity Perks license so we can assist you further.
Best,
If I understand correctly, users should complete the form to “register” and then must complete it to access the content, right? Is there any possibility that the content is unlocked directly when it is completed for the first time? Something like unlock on submission. Thanks again.
Hi Gatson,
By default, the page should be unlocked when the form is submitted the first time. I’ll suggest you set the page as the confirmation page of the form so that when the form is submitted, they would be redirected to the same page but this time they would get access to the form since they already submitted it.
Best,
Hi Samuel, thanks for your answer. If you see here it is not working correctly, the page reloads correctly but it keeps showing me the form again.https://cariboutestsit.wpengine.com/downloads/ Any idea why?
Hi Gaston,
If the snippet setup is correct, it should work. If you have an active Gravity Perks license, you can get in touch with us via our support form so we can assist you further.
Cheers,
How i enable ajax for this form? Because we dont use shortcode here.
Hi Gaston,
You should be able to enable AJAX in the form editor as with any form if you are not using a shortcode.
Best,
Hi! This plugin is awesome, but for some reason my hidden content only shows if the user has been logged into the admin side of the site itself even if I have submitted the form? the cookie gwsa cookie is being stored correctly but only shows the hidden content if the wordpress log in cookie is stored as well. Wondering if there is a fix for this
Thanks, Cierra
Hi Cierra,
I’m not really sure what’s happening and we may need to dig further to confirm why it isn’t working for you. One thing you can do on your end is to exclude that page from being cached. You may also want to get in touch with your hosting provider and have them exclude the page from being cached on their end too. If it’s still not working, then you can get in touch with us via our support form if you have an active Gravity Perks license, so we can dig into this further.
Best,
As a future feature, would you consider adjusting the plugin to allow the display of the form title and description? I see in the plugin code the
gravity_form
function is set to disable those. It would be great if those settings were optional instead.In the meantime I’ve had to edit the plugin to allow those to pass through. My client wanted the signup form to appear as a popup on the same page, and so those extra text elements make a big difference.
Otherwise, I really appreciate what you’ve built. Worked well for my use.
Cheers.
Hi Aaron,
I’m glad to hear you were able to put together a solution.
Thanks for the feedback. I’ll pass it on to our product manager.
Hello!
Do you have extended documentation for collecting a fee to the form before viewing?
Thanks!
Hi Meredith,
We do not have documentation on that. However, I think if you set up a Payment addon feed on the form, it will request the user makes a payment before they can submit the form and get access to the page.
Best,
This plugin is great. The only problem is that as an administrator I am unable to see the pages also. All pages are set to redirect to a form page if they have not filled it out. Is there a way to make administrators exempt from this when they are logged in?
Hi CB,
This is currently not supported and it will require some customization to the snippet and snippet customization is only available to our Pro Customers. So if you have an active Gravity Perks Pro license, you can get in touch via our support form so we can get our developers to look into your requests.
Best,
Hi there, Thanks for the plugin! In my case the user is submitting the form and the confirmation is redirecting to the same page. Is it possible for the form to be hidden if the user has already submitted it? Thanks, James
Hi James,
The issue you describe seems related to the cache. You can try the Cache Busting plugin and if that doesn’t work and you have an active Gravity Perks license, you can reach us out via support.
Best,
How can I have the form submission redirect to the same page (page that the form was on) after? I have a form on a CPT page that shows a video once the form is submitted.
Hi Christina,
You’ll have to set the confirmation page of the form to the same page. This way when the form is submitted it reloads the page but this time the user would get access to the content.
Best,
Hi there,
Is there any way to configure this to allow for recaptcha to work on the gated form?
Thanks much!
Hi Bryan,
There isn’t any known issue using Recaptcha with this snippet. If you’re experiencing any issues using Recaptcha on the gated form when using the snippet, then you can get in touch with us via our support form, if you have an active Gravity Perks License, so we can dig into this issue.
Best,
Thank you for this plugin! I had some trouble, but eventually got it sorted so I thought I’d leave some feedback in case it helps others.
First, I couldn’t find Custom Fields – it’s in a different spot in the Gutenberg editor (the screen shot shows the classic editor)
I still couldn’t find them and found out that if you have ACF active with Gutenberg, they don’t show. I just ended up creating the fields in ACF, but I found this snippet you can use to restore the default custom fields, if you want https://plugin-planet.com/fix-custom-fields-not-showing-wordpress/
I had an issue where it just showed the confirmation message, but not the page. I realized I needed to set the confirmation to redirect. That might seem obvious, but it’s not in the instructions. I normally just use the confirmation text so it didn’t occur to me right away that I needed to change that.
Hi Jodi,
Thanks for sharing these tips.
Cheers,
Really appreciate the heads up about ACF, I was scratching my head. Hopefully the content can be updated in the documentation to reflect this and the new block editor.
Can’t seem to get this to function properly-
Have Page A with a Form on it- form is set to Redirect to Page B, Page B is set to redirect to page A, if a user hasn’t filled out the form already.
Results in an infinite loop- despite filling out the Form- cookies never seem to get set, and so it redirects from Page A to Page B, then page B redirects right back to A.
WP engine site- and WP Rocket is installed- I set settings to never cache the gwsa cookie, and never cache any of the pages involved- but still can’t make it work correctly. Any ideas?
Hi Greg,
I’m guessing this has to do with WP Engine caching. Can you please try the following and see if it helps. Can you get in touch with the WP Engine support and have them exclude Page A and Page B from being cached and see if that helps.
Best,
How do you make it so that they must submit the form every time they access the page meaning when they leave the page and return to the page in the same session or in a new session, they must submit the form again in order to access the page again. I do not want the access regulated by “cookie” since cookie functionality is wonkie depending on device/browser, instead, I would like them to have to submit the form every single time they access the page regardless of session. I have a mobile phone number OTP verification field in the form so that only mobile phone numbers that are in my database can submit the form. Again, how do you make it so that they must submit the form every time they access the page meaning when they leave the page and return to the page in the same session or in a new session, they must submit the form again in order to access the page again?
Hi Ron,
If you set the is_persistent parameter of the configuration to false, site visitors will be required to resubmit the form if they leave the page and return to the page later.
Best,