How to Restrict Access to Content with Members
In this section of the guide to the Members plugin, we will show you how to restrict access to a page/post by adding restrictions to the Content Permissions area of a post/page.
For this example, we will restrict access to the page Restricted Permissions and customize the Error Message.
Step 1) Login to the WordPress Dashboard.
Step 2) From the left-hand sidebar of the Dashboard navigate to Pages -> Add New.
Step 3) Complete the fields as outlined below:
|A.||Page Title||Enter a Page Title.
For this example, Restricted Access was entered.
|B.||Page Body||Enter text for the body of the page.
For this example, a small paragraph was entered (see screenshot below).
|C.||Content Permissions||Place checkmarks in the appropriate checkboxes for the Role(s) you want to restrict access to.
For this example, the Administrator and Editor will be the only Roles that can access this page.
|D.||Custom Error Message||In this area, you can add Shortcodes. Below are examples of the available Shortcodes.
For this example, 1. will be used.
If you have completed the fields as outlined above, the page should now look as follows:
Step 4) Click the Publish button to complete this process.
Testing the Code
Step 5) From your site, navigate to the newly created page, Restricted Permissions. If you are logged in as an Administrator or Editor you should be able to view this page.
Step 6) Log out.
Step 7) Log in using the login credentials for the User, Brad Smith created in an earlier guide and assigned the Role of Quality Control.
Notice that Brad can not view the content of this page instead the Custom Error Message created above is displayed.
The next step of the guide will focus on How to Extend Members with Functions.