Resources     Blog  

  1. Home
  2. WordPress Tutorials
  3. How to Restrict Content by User Roles in WordPress

How to Restrict Content by User Roles in WordPress

Do you have content you only want certain WordPress users to access? Perhaps you’re using a paid subscription platform on your site. Maybe you just don’t want anyone but your editors to access certain posts and pages.

Whatever the reason, you can restrict content by user roles in WordPress. Unless the registered user has a certain role attached to his or her account, you can display a message or even redirect unauthorized access.

In this tutorial, I’ll show you how to enable a WordPress page access control based on the roles of your users.

Using Profile Builder

Today, I’ll demonstrate some of what Profile Builder can do. It’s a plugin that has a wide range of abilities such as monitoring user roles when it comes to showing certain content. This is in addition to creating a great way for users to register.

Install and activate the “Profile Builder” plugin.

Activate Profile Builder

Upon activation, you’re taken to the basic information of Profile Builder. For now, I’m going to assume that you allow user registration.

Enabling User Restrictions

By default, user restrictions are disabled. We’ll have to turn them on manually.

Click the “General Settings” link from the left panel.

General Settings

Select “Yes” from the Content Restriction drop down box.

Enable Restrictions

Scroll down and click the “Save Changes” button.

Save Changes Button

Profile Builder will then add the feature to its list of tools as well as post and pages.

Setting Up Restrictions

Click the “Content Restriction” link from the left.

Content Restriction

Profile Builder gives you two ways to manage unauthorized access. You can either use a custom message for users or redirect them to a specific URL. This is ideal if you create a registration landing page specifically to inform users about the benefits of registering.

Restrict Content Messages

How you set this section up is completely up to you and your ideas for the website. You can even show the first so-many words of the post or page before denying users as a kind of teaser to register.

In any case, click the “Save Settings” button on the bottom after making your changes.

Save Settings

Setting Posts and Pages for User Roles

Now that you have your restrictions set, it’s time to enable them on your content. This feature is now accessible from any post or page you have in WordPress. This includes most custom post types you have as well.

For now, let’s just see where the function is located. Go into any page you want to restrict.

Page Restriction

Scroll to the bottom of the page to the Page Builder portion.

Profile Builder Portion

Choose the type of restriction. You can leave it as your default that you set earlier. However, you can also choose to use the message or redirect depending on your needs.

Choose Restriction

By default, all users can access the page whether they are logged in or not. Click the “Logged In Users” checkbox. This will then allow you to select the users you want to have access to the page.

Logged In Users

Check all of the boxes of user types you want to have access to the page. As you can see, your custom roles are also available as are any that are created from other plugins.

As an option, you can enable a custom message to show on the specific page aside from the default you set earlier. This gives you a chance to customize each page or post for the audience.

However, this is completely optional and only if you don’t want to use the default messages from the Content Restriction page.

Click the “Update” button and your page is then protected by restrictions.

Update Button

Do you need to use the rest of the Profile Builder tools to use this feature?

Restricting pages and posts by user role in WordPress works whether you take advantage of the other tools in Profile Builder or not. However, Profile Builder does have a lot of excellent tools for user registration including Google reCAPTCHA integration.

This helps keep the spam down from user registrations.

You may want to spend a moment taking a look at some of the other features this plugin delivers. You can even integrate your site with Mailchimp, one of the best email services for marketing campaigns.

The only downside is that not all add-ons are supported by the free version of Profile Builder. It just all depends on how much you want to add to the website.

Keeping Content Private

While you could create a completely private website, sometimes it’s easier to just deny people access to certain content based on their user roles. Profile Builder is perhaps one of the best to use for this purpose, and it comes with a variety of other tools to accentuate the website.

What plugins do you use to prevent spammy user registrations? Do you have your own reCATPCHA key from Google, and how often do you use it?

Author: Kaumil Patel

Kaumil Patel is the Chief Operating Officer of GreenGeeks and has over 13 years of experience in the web hosting industry working for and owning web hosting companies. Kaumil’s expertise is in marketing, business development, operations, acquisitions and mergers.

Was this article helpful?

Related Articles


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.