Are you building a web application with GravityView? Do you need a way to restrict access to your Views?
GravityView is a powerful plugin that extends Gravity Forms by allowing you to display Gravity Forms entries on the front end of your website. Using GravityView you can build membership websites, intranets, databases, and more!
In this post, we’re going to look at all the different ways to protect your Views by login status or user role. There are different ways to do this based on the effect you want to achieve and the good news is that you won’t need complicated or bulky membership plugins!
Are you ready? Let’s get started.
Why Restrict Your Views?
Having the ability to restrict access to Views is helpful for a number of reasons.
For example, you may want to create an in-house database that contains sensitive information related to your brand or business. Having that information exposed to the public might cause privacy issues for you and your employees.
Restricting your Views can also be helpful if you run a membership site and you want to restrict content to registered users.
Disabling Direct Access to Views
Before we get started showing you how to protect your Views based on login status or user role, it’s worth reminding all GravityView users that you can disable direct access to your Views.
What does this mean exactly?
Well, disabling direct access means that users will only be able to access Views through the page they are embedded on and not via the View URL. This ensures users see the specific page you have created for your View instead of the default page that WordPress creates.
To disable direct access to your View, click Edit on your View, scroll down to the Settings box, click on the Permissions tab and check the box that says “Prevent direct access”.
Okay, now let’s look at a few different ways to protect your Views.
1. Password Protecting Your Views and Pages
WordPress gives you the ability to password protect pages, posts, and Views.
To password protect your View (or a page where your View is embedded), click on the Edit link next to Visibility. Next, check “Password protected” and enter your chosen password.
Now when a new user visits your View, they’ll be asked to enter the password. After entering it, they will be able to see your View and all its content.
You can also restrict access to your View by making it “Private”. If you select this option only administrators and editors will be able to see your View and its content.
These two options work well as a basic means of protection. After all, this is standard WordPress functionality that doesn’t require a third-party plugin or any complicated setup. However, if you’re looking for a more sophisticated and flexible solution, check out the options below.
2. Hiding Certain Fields in Your View
GravityView gives you the ability to restrict access to certain fields based on login status or user role.
This is a great option if you want some information in your View to be public and other information to be private. For example, some product marketplaces allow the public to access product listings but restrict seller information to registered users.
To do this, edit your View and click the gear icon next to the field you want to restrict. This will bring up the Field Settings window. Under Visibility, check the box that says “Make visible only to logged-in users?”.
To restrict visibility to specific user roles, select a role from the dropdown menu below. The different options are:
- Any Logged-In User
- Author or Higher
- Can View gravity Forms Entries
- Editor or higher
- Can Edit Gravity Forms Entries
If you want to take things a step further, you can use the Advanced Filter extension to restrict specific fields based on conditional logic.
3. Using the Members Plugin
The WordPress Members plugin by MemberPress allows you to restrict access to content on your website. It’s effective, powerful, and best of all, free.
To get started, log in to your WordPress site, hover over Plugins in the left-hand menu and click on Add New. Next, search for “Members – Membership & User Role” and install the plugin.
After activating the plugin, you’ll see a new meta box at the bottom of your pages and posts, allowing you to restrict access to specific user roles.
If you embedded your View on a page, you can wrap the embed shortcode in the [members] shortcode to restrict access. To restrict your View to logged-in users, use the [members_logged_in] shortcode:
[members_logged_in] [gravityview id='47'] [/members_logged_in]
To restrict your View to certain user roles, use the [members_access] shortcode and define a user role, like so:
[members_access role="editor"] [gravityview id='47'] [/members_access]
Making your entire site private
The Members plugin also gives you the ability to restrict your entire website! This is helpful if you’re running a private membership site.
Hover over Members in your WordPress sidebar and click Settings. Next, scroll down and check the box that says “Enable Private Site”.
But what if you need to create custom user roles with different capabilities? You can do that too!
Creating new user roles
To add a custom user role to your website hover over Members and select Add New Role. Give your new role a name and select from the capabilities that you want the role to have. For GravityView-specific capabilities, click the GravityView tab on the left.
Okay, let’s have a look at using the Redirection plugin to protect Views based on login status or user role.
4. Using the Redirection Plugin
Finally, you can restrict access to your Views by using the Redirection plugin to redirect users based on login status or user role. Redirection is a free WordPress plugin that allows you to create different types of redirects for URLs on your website.
After activating the plugin, create a new redirect rule for the page where your View is embedded. Next, click on the gear icon to bring up additional options.
The Match dropdown menu allows you to configure redirects based on the user’s login status or user role.
The dropdown menu next to When Matched allows you to choose the type of redirect you want to set up. For example, a 301 redirect is different from a 308 redirect. However, for this particular use case, it’s best to select Pass through.
For more information on HTTP status codes and redirects, check out httpstatuses.com.
For a full video course on using the Redirection plugin to protect Views in GravityView, check out our free course on Gravity Guide!
Restricting Views in GravityView: Final Thoughts
With numerous layout options and extensive customizability, the GravityView plugin is the best way to display Gravity Forms entries on your website.
If you use GravityView on your website, you may be looking for a way to protect your Views based on login status or user role. In this post, we shared with you 4 ways to restrict your Views.
Password protect your Views using default WordPress functionality or restrict certain fields in your View using GravityView. And for a more flexible solution, use a plugin like Members or Redirection to protect your pages and posts!
If you enjoyed this post, make sure to subscribe to our newsletter so we can notify you when we publish new content.
Join Our Newsletter!📧🙌
✔️ New blog posts straight to your inbox
✔️ Be the first to hear about new updates and releases