User Registration – Content Restriction Advanced

Advanced Method: #

Setup and Configuration: #

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

After you click on it, you will see the access rule 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:

  • Rule Name: At the top left, you can see a pencil icon and an input box. You can give a name to the rule there. For example, Rule 1, restrict one, etc.
  • Enabled/Disabled Toggle switch: The toggle switch on the top right of the window is used to enable or disable the rule in action. It is enabled by default when you add a new rule.
  • Conditions & Logics:  Here you can define the conditions that the users trying to access your content must meet. For example, you might want the users to be logged in, have certain roles, have certain email domains, etc. You can specify the conditions here.

#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 is necessary. For the demonstration purpose, I have selected all 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. 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.

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 its 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 all 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.
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..
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.

  • Actions: Here you can specify the actions that will be taken when a user who does not meet the access rules tries to visit the restricted content.

#How to setup Actions for restricted contents? #

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 setup the 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 new method takes precedence over restricting 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.

Powered by BetterDocs