View Categories

Content Restriction

You can use the Basic Content Restriction feature with the User Registration & Membership Free Plugin through the global settings. For Advanced content restriction, you’ll require User Registration & Membership Pro.

Whole Site Restriction (New Feature) #

You can now restrict access to your entire website with one setting. For settings, navigate to User Registration & Membership > Settings > Content Restriction.

This option is available on User Registration & Membership v4.0 or above.

Enable Whole Site Restriction: Toggle to enable whole site restriction.

For further settings, like who is restricted, and what is shown to the users who try to access the restricted content, you can configure through global settings.

GLOBAL RESTRICTION SETTINGS #

Either you’ve enabled whole site restriction or individual page/post restriction, you can configure the restriction settings from here. This setting affects both the whole site and individual page/post restrictions:

  1. Allow Access To:
    From the drop, choose who can access restricted content:
  • All Logged-In Users
  • Specific User Roles (e.g., Admins, Editors)
  • Guest Users (non-logged-in visitors)
  • Memberships (custom subscription tiers)
  • Restricted Content Message:

Set the message which you want to display, to unauthorized users.

Click on the Save Changes button, once you complete configuring Content Restriction global settings.

Example: You can Enable Whole Site Restriction and allow access to All Logged in Users. Guest users will see your custom message.

Individual Page/Post Setting for Content Restriction #

If you want to override the content restriction setting for certain pages or posts you can do so from individual page/post settings:

  1. Navigate to page/post. At the bottom of the page, you’ll see Content Restriction Settings:

Restrict This Content #

Perfect for restricting specific paragraphs or sections.

Use the shortcode [urcr_restrict]"ADD YOUR CONTENT HERE"[/urcr_restrict] to restrict partial contents.

Restrict Access to Page/Post #

If you have enabled Whole Site Restriction, Restrict Access to This Page/Post setting will be enabled by default you don’t have to make further changes from here.

When Whole Site Restriction is Enabled

If you have not enabled Whole Site Restriction but want to restrict this page/post, you can check on Restrict Access to This Page/Post option and enable the restriction.

When Whole Site Restriction is Not Enabled

Override Global Settings #

You can change the access control for the page/post by enabling Override Global Settings. It allows you to override the Access control setting for that page or post, even if the global restriction settings are different.

Under Allow Access To, you can specify which user roles can view the page/post.

For example, if your global settings allow access to both Administrators and Editors, you can override this for a particular page and grant access to Administrators only.

If you want to keep the global access settings as they are, simply leave Override Global Settings unchecked.

Save the changes made on this page/post.

When the unauthorized users tries to access the page, he/she should get the content restriction message as shown in the image below:

Example of Content Restriction
Example of what happens when non-authorized users tries to access restricted content
Global vs Individual Settings:
Global restriction settings serve as a default restriction
Individual pages can override global settings if required
Whole site restriction takes precedence unless overridden

Partial Content Restriction #

You can also restrict the partial contents of the pages or posts. Use the shortcode [urcr_restrict]...[/urcr_restrict].

This will restrict the paragraph under the shortcode. Who can see these contents depends on the global settings similar to full contents.

To override global settings to specific posts/pages. You can pass the parameter access_role to the shortcode. When you pass parameters, the settings in global does not matter.

Examples:

[urcr_restrict access_role ="administrator"]  will allow access to the only administrators.

[urcr_restrict access_role ="guest"]  will allow access to only non-logged in users.

[urcr_restrict access_role ="administrator,contributor"] will allow access to administrators and contributors.

To allow access to all logged-in users: Pass argument access_role with a value all_logged_in_users.

e.g. [urcr_restrict access_role ="all_logged_in_users"]

Message in the settings allows you to write the message instead of the restricted contents.

Partial Restriction for Elementor sections #

You can restrict the sections of the Elementor partially from the section’s advanced settings. Go to Edit Section > Advanced and on the Advance tab, you will find the option to restrict that section.

Frontend

Content Restriction Block #

Just like other Gutenberg blocks, you can add a Content Restriction block on your page/posts. Anything inside this block will have the content restriction’s global settings applied.

  • Go to Page/Post editor.
  • Click on the + button on the top-left.
  • Search for the Content Restriction block and click on it.
  • Once the block is added to the page builder section, you can insert other blocks within this Content Restriction block. Anything inside this block will take the condition for the Content Restriction’s global settings.

Advanced Method: #

Installation #

  1. First, you need to purchase the User Registration Premium to get the User Registration Pro plugin/add-on.
  2. After the successful purchase, you will get the plugin zip file under your WPEverest account page.
  3. Now, you can download the plugin zip file from there.
  4. Through your WordPress Dashboard, visit Plugins -> Add New -> Upload and then choose the downloaded zip file and then install and activate it.
  5. Now you are ready to use this add-on for your site.

Setup and Configuration: #

Go to the access rules page by clicking on the sub-menu Content Rules.

After you click on it, you will see the Content Rules window where you can add content access rules. You can set rules using conditions and logic, select what content to restrict, and also define what to do when someone tries to access the restricted content. You will see everything explained below in a step-wise manner.

Adding a New Rule: #

Click on the Add New button to add a new rule.

After clicking on Add New, you will see a window as shown below:

Give a name to the rule and choose whether you want to create an access rule or a restrict rule. Access rules provide access as per the condition you will set and the restrict rules will restrict the content. Then, click on Continue.

How to define the conditions? #

After you click on Add New, you will see that you are in the Conditions & Logics Tab by default and a Main Logic Group Section appears by default inside the Conditions & Logics Tab. You have the option to Add Fields where you can choose from various fields and set values to them and Add Groups where you can add a group inside which you can again add different fields or sub-groups.

Adding Fields #

Click on the Add Field button and you will see a dropdown with a list of options where you can choose between various fields to set up a condition.

You can select those from the list that you feel are necessary. For the demonstration purpose, I have selected some of them to let you know the purpose.

To view the content following rules must be followed:
User Based:
1. Roles: Users must have any one of the selected roles.
2. User Registered Date: Users must be registered within the selected date range.
3. Period After Registration: You can set the number of days during or after which the user is given access to the content.
4. User State: You can define whether the logged in or logged out users are able to access the content.

User Asset Based:
1. Email Domain: Specify particular email domains so that users with the specified email domain can only view the restricted content. You can specify multiple email domains separating them with comma. Like, gmail.com, hotmail.com, wpeverest.com, etc.
2. Minimum Public Post Count: The content visiting user must have minimum specified posts on your site as public.

Others:
1. Capabilities: The content-visiting users must have all the listed capabilities to access the content.
2. User Registration Source: Users must be registered from any of the defined sources to visit the content.
3. UR Form Fields: This field lets you choose the form field from any of the available User Registration forms. You can set a conditional logic so that the restriction/access happens when the form field value matches the condition.

Adding Groups:
Click on the Add Group button and you will see a sub-group appear inside the main logic section. Sub-Group can contain fields or other another sub-group of their own. You can consider the sub-group like any other field to avoid any confusion while setting up the rule.

In the above screenshot, you can see that I have added two fields(Roles and User State) and a group inside the Main Logic Section. I have added the fields by clicking on Add Fields and added the group by Clicking on Add Group of the Main Logic group.

You can also see that I have added a field(Allowed Email Domains) inside the Sub Logic Group. You can add fields inside the sub logic group by clicking the Add Fields button of Sub Logic Group. You can also add a group inside Sub Logic Group by clicking on the Add Group button of Sub Logic Group.

Main Logic Group Operators:
You can see the option to set OR | AND | NOT right next to the Group name.

These three logical operators perform the selected operation on the fields and groups inside the Main Login Group. For Example, see the above screenshot.
– If you selected OR, then the user visiting the page will only be able to see the restricted content if the condition specified in either Roles, or User State or Sub Logic Group is true.
– If you selected AND, then the user visiting the page will only be able to see the restricted content if the condition specified in Roles, User State, and Sub Logic Group is true. All three conditions must be met i.e all three must be true.
– If you selected NOT, then the user visiting the page will only be able to see the restricted content if the condition specified in Roles, User State, and Sub Logic Group is not true. All three conditions must not be met i.e all three must be false.

Note: Similar functionality is available for the Sub-Logic Group Operators but it works for the fields/groups inside it.

Deleting the Fields/Groups:
To delete a field or a group, simply click on the bin icon at the rightmost part of the field or group and it will remove the element.

  • Target Contents: Here you can specify the contents that you want to restrict. It could be Pages, Posts, Taxonomies, or Post Types.

How to select the content for restriction? #

After you have set up the rules to access the contents in the Conditions & Logics Tab, you will need to specify the contents to be restricted. To do so, click on the Target Contents Tab and then click on the Add Fields button inside the Target Contents Tab. You will see the following options.

You can select those from the list that you want to restrict. For the demonstration purpose, I have selected some of them to let you know the purpose.

You will need to specify the contents for the options that you have selected to restrict.
Post Types: Select the Post type that you want to restrict. All available post types will show up on the list and you can choose the ones you want to restrict. When using the WooCommerce plugin, you can select the ‘Product’ post type to restrict or provide access to the users from/to the Products.


Taxonomy: Select the taxonomy that you want to restrict. All available taxonomies will show up on the list and you can choose the ones you want to restrict. If you use the WooCommerce plugin, you can select the product categories that you would like to restrict.


Pick Posts: You can select one or many posts from your site to apply restrictions.
Pick Pages: You can select one or many pages from your site to apply restrictions.
Whole Site: You can restrict all of the content on your site if you select this target.

Restrict Whole Site #

For restricting the whole site, go to Target Contents, click on Add Fields and select ‘Whole Site’.

After this, the users that match the condition will be given access to the whole site and others will be restricted.

Restricting whole site for logged out users will also restrict them from viewing the login and registration forms which isn't convenient. If you restrict whole site for the logged out customers, you will then have to either render the login form shortcode or select 'Show Message' option for the Action section. While showing the message, you can add the registration and login form shortcodes so that the logged out users can either login or register to your site.

How to set up Actions for restricted content? #

After you have selected the contents for restriction in the Target Contents Tab, you will need to specify the actions that will be taken when a user who is not eligible to visit the content tries to see/access the content. To do so, click on the Actions Tab and then select an action from the list of available actions. You will see the following options.

Here is the description of each of them:
1. Show Message: After you select this option, you will be able to show a custom message to the users if they try to access the restricted content. You can add a link or show a formatted message using HTML to your users.

2. Redirect: After you select this option, you will be able to redirect non-eligible users to a custom URL that you will need to specify in the URL input section that will appear after selecting this option.

3. Redirect to a Local Page: After you select this option, you will be able to redirect non-eligible users to a page within the website. You can select a page from the dropdown section. The dropdown will show all the pages of your website.

4. Show UR Form: After you select this option, you will be able to show a User Registration Form to non-eligible users. You will need to select the form from the dropdown that will appear after selecting this option.

5. Render Shortcode: After you select this option, you will be able to show the different contents to non-eligible users using the shortcode from the available shortcode list. You can also specify the extra attribute of the shortcode in the input there.

Finally, you will set up the advanced content restriction on your site.

Note: The previous way of restricting content hasn’t been removed or changed so the rules you set before should work just fine even if you’re using this feature. However, please keep in mind that the new method takes precedence over restricting the same contents. For example, let’s say you restricted a post using the old method. Then, you created a new Access Rule to restrict the same post. In this case, the access rule will restrict the content, however, if it doesn’t perform restriction then the old way of restricting starts running.

Restrict Files: #

In WordPress, images and files in the media library can be accessed directly via their URLs.

If you want to restrict access to these files, follow these steps:

Powered by BetterDocs

Scroll to top