TUTORIAL

How to Restrict Access to WordPress Pages and Post by User Roles?

Last Updated: 4 mins By: Alina Manandhar

If you have a website, there might be a time when you need to restrict the content of your site to certain people. You might want to set the content of the site visible to only logged in users or be even more specific and make it visible to logged in users with specific roles. WordPress allows you to assign each logged in user with specific roles. One can then use this role and set content to be either visible or hidden. But, how do you restrict WordPress content to specific user? Don’t worry!

In this WPEverest article, we are going to teach you how you can restrict content by user roles with no trouble.

Why do you need to restrict content by user roles?

One thing is for sure; all of your visitors are not the same. When there is a number of people visiting your site you might want some confidential things to be accessible to a certain type of users with higher authority. Likewise, there are usually different types of plans and programs that customers sign in for according to their needs. So, you might need to restrict WordPress pages and content to the user as per the plans.

For example, you want to show the accounts page of your website to only premium users then, what do you do? This is where our Content Registration Add on comes in handy.

How to Restrict WordPress Pages and Content to specific user?

In a WordPress site, you can assign different roles to your users such as administrator, author, editor, contributor, subscriber, etc. You can even use some plugin to create custom roles like customer, member, student or similar. Then based on what roles they have, you might want to restrict content

Before assigning roles and restricting content to the users, you must first make your users register to your site. Our User Registration plugin is one of the best form plugins to make your users register in your site. So, go on and, install User Registration plugin first.

User Registration Plugin
User Registration Plugin by WPEverest

With User Registration, you can create registration forms with no trouble at all. It has the easy-to-use drag-and-drop form builder feature. So, anyone can create registration forms for their site.

Moreover, you can choose which user roles to be assigned to the user once they have filled the registration form. For this, go to the General Settings tab in the form builder. And, select the Default User Role.

Then, you need to get our premium Content Restriction Add on.

Content Restriction Add On
Content Restriction Add On

The Content Restriction Add-on is available on all of our premium plans.

If you want more details on the pricing, go to our Plans and Pricing page to choose the best plan for you.

Full Content Restriction

After you install and activate the Add-on, go to User Registration tab then, click on Settings. Then, click on the Content Restriction tab.

content by user roles there

Now, click on the drop-down option to Allow Access To specific roles. Then, Select the roles you want to restrict access to. Also, don’t forget to add the restriction message that will be shown to restricted users.

restrict content by user roles

After that, go to the post or page that you need to restrict. In the bottom of the page, you can see the Restrict This Content box. And, check the Restrict Full Content option.

restrict content by user roles

Not only can you restrict content by user roles but, you can also make any particular page or post accessible to specific users only.

Below the Restrict Full Content option, there is the Override Global Settings option. Check that option. Then, click on the drop-down menu for the Allow Access To option and select Choose Specific Roles.

After that, simply choose the user roles you want to give access to from the Allow Access To Roles option.

restrict WordPress pages and content to specific user

Partial Content Restriction

Similarly, you can also restrict content by user roles partially. The Content Restriction add-on provides a shortcode for that. Just insert the content you want to restrict inside the given Shortcode and, your job is done!

restrict content by user roles six

After you restrict pages or content by user roles, the user will see the restriction message you set up when they try to access that content or page.

restrict content to specific user

Wrapping up!

Hence, there are various reasons you need to restrict WordPress pages and content to specific user. According to your business plans and programs, there may be customers with different user roles. Similarly, you can restrict pages and content to the members of your website. Hopefully, you can now restrict content by user roles effortlessly with the help our User Registration Content Restriction Add on.

If you found this article helpful, don’t forget to share!

Alina Manandhar

Leave a Reply

Your email address will not be published. Required fields are marked *

10 thoughts on “How to Restrict Access to WordPress Pages and Post by User Roles?

  1. Only problem I had was trying to use capcha because I did not get API code and I turned off normal wp login. Plugin did not complain and the result was I could not login becasue capcha value was incorrect (it was not on the login form) and I could not login via wp-admin. Had to delete plugin and restart. Also noted that database entries were not removed when plugin deleted probably because it was deleted not removed. I could not see anything but a good feature would be a no activity expiry time to force logoff.

    1. Hi @geoff,

      Thank you for mentioning the query in detail. I can see that the issue of Captcha caused you to be locked out of your site. Trying to replace WP login is important and also a critical part of the process. It is recommended that the Prevent Core Login should only be checked if the login form is fully functional. Once you enable the Recaptcha, first make sure that it is working fine when trying to log in using the login form. Once it is working fine, you can then enable Prevent Core Login to replace the default login. This will ensure both safety and reduce the risk of being locked out.

      Also, from our side, we have taken this issue in the account and in the upcoming version of the plugin we have included a slight enhancement in that part which we believe will reduce the risk of getting locked out. So, please keep looking for updates.

      Lastly, please go through this documentation https://docs.wpeverest.com/docs/user-registration/google-recaptcha-integration/ once to ensure that you have set up the re-captcha properly.

      I hope this information helps. Let me know if there is anything else I can help you with.

      Regards!
      Deepak

    1. Hi Geoff,

      With User Registration Content Restriction, you can restrict either posts or pages entirely or its content partially. Menu items cannot be restricted using the content restriction add-on.

  2. With User Registration Content Restriction, you can restrict either posts or pages entirely or its content partially. Menu items cannot be restricted using the content restriction add-on.

  3. Hi Deepak,

    Can I make separate login and registration forms for different types of users? For example, one form for buyers that has it’s own specific roles and one form for sellers that has it’s own specific user roles?

    1. Hi @Barry,

      You can make separate registration form for separate users but why do so if you can do that with a single registration form. I mean, you can let your users choose a role from the frontend using the conditional logic feature of the plugin. You can learn more about how it works here: https://docs.wpeverest.com/docs/user-registration/how-to/how-to-conditionally-assign-user-roles/

      And regarding login form, Please refer to this link https://docs.wpeverest.com/docs/user-registration/registration-form-and-login-form/how-to-show-login-form/ to learn about creating a login form. lastly, the login form will work for all users so you do not need to make separate login for all. But incase you want to, you can do that.

      I hope that helps. For more queries, contact us here: https://www.wpeverest.com/contact

      Deepak Sharma
      WPEverest

  4. Hi Deepak,

    Can I restrict the content of a post for everyone and show only to a specific user (not user role)?

    Thanks

  5. I’m thinking about getting the plugin but one thing holding me back is subscription handling. Is it possible to handle role subscriptions with this plugin or would I have to use another plugin? If so which one would you recommend?

Scroll to top

Pin It on Pinterest