Tired of your valuable content being available to everyone?
Well, not anymore. In this tutorial, we’ll walk you through the step-by-step process of restricting content in WordPress to non registered users.
We assure you this is what you’ve been looking for!
Prerequisites for Content Restriction
First, we’ll require a plugin that allows user registration and a content restriction feature.
User Registration Plugin
The User Registration plugin lets you register users on your website through your forms.
First, visit the User Registration website, choose a plan that suits your needs, and download the plugin from your account page.
After installing it on WordPress, follow the setup wizard for a quick and easy configuration. If you prefer a more detailed guide, check out the article on installing and setting up the plugin.
Content Restriction Addon
The Content Restriction addon from User Registration will allow us to restrict content on our website.
Let’s first enable the Content Restriction feature.
- Go to User Registration >> Extensions.
- Search for “Content Restriction” on the search bar and install the addon by activating this toggle.
Then, you’ll have to enable Content Restriction for the User Registration plugin.
- Go to User Registration >> Settings >> Content Restriction.
- Click on this toggle to activate it.
Now, go to User Registration >> Content Rules.
Click on the Add New button.
You’ll encounter this popup. Give a name for your set of rules, which will help you identify and select whether you want to provide access or restrict this rule.
You can change both of them later, too.
After that, you’ll enter this window. The first stage is labeled Conditions & Logics, where you can select who can gain access or get restrictions.
You may use the OR, AND, and NOT operators by clicking on them.
If you aren’t a computer geek,
- OR: The rules will apply if one of many conditions is met.
- AND: The rules will not apply if any conditions are unmet.
- NOT: The rules will apply if the condition isn’t met.
To add conditions, you’ll have to click on + Add Field button.
We’ve listed the conditions below so you may know what conditions you can control.
You may also add sub-groups inside a Group. To do so, click on + Add Group.
Next, go to Target Contents.
Here, you can choose the parts of the website that you want to restrict.
Click on the + Add Field button. You may select from here.
You can target specific post types, taxonomies, posts, pages, and even the whole site.
Other options allow you to select multiple sub-options except for the whole site.
Moving to the Action tab, you can decide what the plugin should do.
You can choose whether you give access or restrict the selected roles from the targeted content.
You can also select the action for users with restricted access to this setting. Here’s the list:
You may choose only one of the listed actions.
Restrict Content in WordPress
When it comes to restricting content in WordPress, the challenge is ensuring access to the right content, whether it’s pages, posts, or entire website.
Luckily enough, we have multiple solutions to address these needs. Follow the one you require for your website.
Restrict WordPress Site to Non Registered Users
We’ll restrict the whole site to non-registered users.
For that, create a new Content Rule. For this, go to User Registration >> Content Rules.
Then, click on the Add New button.
You’ll be sent to the Conditions & Logics page.
Here, create a new field by clicking on + Add Field and select Roles.
Here, select the roles you wish to provide or restrict access to. Since we’re limiting access to non-registered users, we’ll select all the roles for now and only give them access.
Then, go to Target Contents.
Click on the + Add Field and select Whole Website.
Move to Action tab.
Select Access to access the selected roles on the Access Control field. Since we selected all the roles, non-registered users can’t access your site.
You may select the appropriate action you want to set for them when they access your website.
But wait! How will users access the registration or log-in forms if I restrict the entire site? How will they gain access?
For this, you can either select Show Message, or Show UR Form action.
Show Message will help you display a message and forms to fill out.
Show UR Form will only display a single form without any message.
If you want logged-out and non-registered users to be able to log in or register simultaneously, we recommend you choose Show Message.
For this, click on Action field and select Show Message.
After typing out your message, click on the Add Registration Form button.
A popup will appear where you can select the form you want to display.
Select your registration form.
To display your log in form, you’ll need to add the form’s shortcode.
Go to User Registration >> All Forms.
Go to the Login Forms tab. You’ll find this shortcode for the login form on the right side.
Copy it and paste it into the text field.
Here’s a preview of it.
Restrict WordPress Page/Post to Non-Registered Users
Now, let’s learn how to restrict WordPress page. Go to Content Rules.
Create a new rule with a unique name and access control.
On Conditions & Logics, create a new field by clicking on + Add Field and choose Roles.
Select the roles you want to give access to or restrict from.
Let’s select every role to restrict non-registered users from accessing our page/post.
Then, on the Target Contents tab, click on + Add Field. You may select from either Pick Pages or Pick Posts.
We’ll now select Pick Pages and click on the empty field to select a random page.
You can add multiple pages/posts by selecting them.
On the Action tab, select Access Control to choose whether you provide access or limit access to the selected roles. For now, we’ll choose Access.
Let’s redirect users to the Registration page to get a role and access your content.
From the Action field, select Redirect from the + Add Field.
Then, enter the URL of your Registration page.
Save your progress, and you’re done.
You may also restrict a specific page/post directly from your page/post builder.
Go to your content below, and you’ll find this setting.
Here, you can choose whom to provide access for the page/post you’ve opened.
If you select all the roles, no one can view the content. However, if no roles are chosen, everyone can view the content, regardless of the user role.
Restrict Section Within a Page/Post (Partial Content)
You can restrict specific parts of content with two different methods.
You can either use a simple shortcode of [urcr_restrict]…[/urcr_restrict] or a Content Restriction block.
First, we’ll show you how to restrict partial content using the shortcode.
Go to any page via Pages >> All Pages.
Open the page. At the beginning of the content, place [urcr_restrict], and at the end, place [/urcr_restrict].
You can easily control who can access our brief documentation, but you are restricted.
Here’s how to add the code to your content as a demonstration. It’ll disable access to all logged-out users only.
And here’s the preview.
Now, let’s try using the Content Restriction block.
Go to any page/post you want to apply the restriction.
We’ll go to a page via Pages >> All Pages.
Open the page and insert a Content Restriction block.
Click on this “+” icon and search for “Content Restriction”.
Select it and add the content you want to restrict inside it.
Then, select the block and go to its Settings. You can select the role from here and choose whether selected roles can access your content.
After you’ve decided, make the changes and save your progress.
Note: To customize the restriction message for both methods, go to User Registration >> Settings >> Content Restriction.
These are the two ways you can restrict WordPress page/post.
Show Content to Paid Users (Members Only)
So, you have a website where you wish to restrict access to your paid content?
We’ve got a solution for that.
You can assign user roles conditionally with User Registration while users fill out the form.
We’ll use this to restrict paid content to non registered users or, much better, specific registered users.
To assign user roles conditionally, we request you refer to this documentation.
We’ve created a Payment Registration form where users can purchase roles directly by filling out your form.
Now, go to User Registration >> Content Rules and click the Add New button to create a new one.
The first page you’ll be displayed is the Conditions & Logics page.
We’ll provide access only to the paid Contributor role. You’re free to select as many roles as you want. If you select all the roles, non-registered users will not have access to the content.
To do that, click on + Add Field and select Roles.
Choose Contributor from the Roles field.
Then, add another field by clicking the + Add Field button and select User Registration Source.
On the Registration Source field, choose the registration form from which users must purchase the role.
Add another field by clicking the + Add Field button and select Payment Status.
Select Completed from the Payment Status field.
Finally, select the AND operator from this section.
Now, go to Target Contents tab.
Click on + Add Field button and select either Posts or Pages that you want to restrict access.
For now, we’ll proceed with Pages. On the Pick Pages field, select your page/pages.
Then, go to the Action tab.
Select Access from Access Control.
On the Action field, let’s display a message letting the users know they require a Contributor role to access this content.
That’s all. Press the Create Rule button at the bottom of the page to activate it.
Note: The above process is specific to the Contributor role, their registration source, and whether their payment has been completed. If you want all paid roles to access the content regardless of the registration source, only include the Payment Status condition and select Completed.
Advanced Content Restriction with Conditions and Rules
Let’s create a more advanced content rule. From this, you’ll be able grant access to a specific page only for users with a designated role who registered through a specific source and used a particular email domain during registration.
This allows you to finely control access based on role, source, and email criteria, ensuring only the right users gain entry to the content.
To do so, we’ll create a new Content Rule by going to User Registration >> Content Rules and clicking the Add New button.
On the Conditions & Logics tab, we’ll need to create three fields.
To do so, we click on the + Add Field.
First, we’ll create a condition where the user has to have the Author role.
For this, select Roles.
On the field, select Author.
Let’s add another field by pressing the + Add Field.
We want users who have registered via Gmail to access this content.
Click on Email Domain.
We’ll type “gmail.com” into the field.
Next, we’ll create another field and select User Registration Source.
We’ll select this Registration Form.
Click on this AND operator to allow users to view your content only if all the above conditions are met.
Move on to the Target Contents tab.
We want to apply the restriction on a page and a post here.
Click on + Add Field and select Post Types.
This will allow us to select all types of Posts, Pages, and Media.
For now, we’ll select all Posts.
Then, move to the Action tab.
Here, select Access in the Access Control field.
Select the action you want to perform on restricted users in the Action field.
For now, let’s stick with the default message.
Press on the Create Rule button, and it’s activated.
Conclusion
Restricting content on your website is essential to maintain control over who can access your valuable resources.
With the methods we mentioned above, you can tailor access to fit your specific needs.
If you’re still confused or have queries, please inform us on our Facebook Community, X.
Frequently Asked Questions
Unfortunately not. The User Registration plugin doesn’t allow that yet.
Yes, you can. You can set specific days for content access both during and after registration. Additionally, you can define a date range to restrict or grant access based on users’ registration, offering flexible control over user permissions.
Yes, they can. You can set multiple content rules and activate them simultaneously.
Certainly! In the Conditions & Logic section, create a field named ‘UR Forms.’ You can select a specific field from your form to establish your conditions. The user will gain access if you choose ‘Access’ in the Action tab and the condition is met. Conversely, if you select ‘Restrict,’ access will be denied.