Site Access Restriction (SAR) - Use Case - How to Build Drip Content Posts
Use Case – How to Build Drip Content Pages.
- Site Access Restriction – This document uses version 1.6.0
Site Access Restriction is a WordPress plugin that allows you to create a membership and content restriction solution. The content restriction is based on user WordPress roles and if they are logged in or not. Choose which post type, category or even specific page should be locked – and to whom.
Use Case Front-End
Use Case Assumptions
In this example we will consider how to build drip content pages. It means that newbie users will not be able to access some post or pages, or event post/page categories for some definite period of time after they registered.
- Installing the plugin
- How content restriction works
- Setting up
- Restricting posts, pages and more
- Restricting specific post
- Restricting definite categories
- End result
Installing the Plugin
The process is the same for all CM plugins and add-ons.
- Download the plugin from your customer dashboard
- Log in to WordPress and navigate to the WordPress Admin → Plugins settings
- Click on Add New
- Activate it and add the license
Learn more: Getting Started - Plugin Overview
How Content Restriction Works
This plugin allows users to create a membership and content restriction solution. The content restriction is based on user WordPress roles and if they are logged in or not.
The content restriction can be set by the following options:
- Specific URL - You can restrict access to specific posts. This can also include URL parameters.
- Specific Post / Page - You can restrict access to a post, page or any custom post type by editing the post and using the post metabox to restrict access.
- Specific Permalink - Some plugins create the fly pages which are only represented by permalink. In such case you can use the admin bar edit option to define content restriction.
- To all posts by type - Using the plugin setting, you can restrict content across all post from a specific type.
- To part of the content - Using a shortcode, you can limit access to part of the content in a post or page only to specific roles user id or user action.
Let's start first with the general setting up the plugin and then consider content restrictions methods step by step.
Navigate to Admin Dashboard → CM Site Access Restriction Pro → Settings.
Head to the General tab.
Here we need just a few settings for configuring drip content pages.
Access denied due to time restrictions - You can select the page where the user will be redirected after they try to visit a restricted page outside of an approved time.
TIP: Create a Page For Temporarily Denied Access
You need to create a page, where the user can see a message that the access is temporarily denied for some period of time.
Restriction type - Here you can choose how much of the content is restricted:
- Restrict full content - Restrict all content on the page.
- Restrict partially content - Showing some percentage of the content with a fade effect and message (configurable in the labels section). The percentage is defined lower in the option Restrict partially content percentage.
- Restrict content with shortcode only - Show all content except those parts that are restricted by the
[access]shortcode. Learn more about this shortcode. Note: This restriction type has no affect when you restrict the access for newbie users for some period of time after registration. If you choose this option, then full content will be restricted for newbie users.
Note: The setting Restriction Type can be overridden for every post type in the next tab Post Types, and it can also be overridden for every specific post or page in the metabox.
Restrict partially content percentage - Set the percentage of how much content should be displayed when the option Restrict partially content is enabled. Default value is 20%.
Restricting Posts, Pages and More
There are a few ways, how you can restrict a page for some period of time after registration. Let's start with restricting all posts of a definite type.
Head to the next tab of the settings - Post Types.
In this section you can restrict all posts which belong to a custom post type, as well as restrict access to the general pages and posts. There is a long list of items that you can restrict.
For our use case, to restrict access to posts for some period of time for newbie users we need the following options:
- Access denied X days from registration - Access is restricted for users that registered less than X days ago. Let's set here the value "14". It means, if the user was registered less than 14 days ago, he won't be able to access all WP posts on your site until that time passes.
- Restriction type - Here you can optionally choose the type or restriction between Global settings or 3 options that override options in the General tab of Settings.
TIP: Choose Restricted Roles
You can also choose which user roles to restrict for X days from registration. Just choose the option Access restricted by role and select user role you want to restrict. It means, only selected user roles will have the access to the chosen post type and only if enough time passed since their registration.
At the end of configuring the settings click the Save button to save the changes.
Restricting Specific Post
You can control the access to specific pages or posts using a metabox located in each page or post once editing the post.
You can edit the posts or pages in two ways.
1) Open the list with posts, for example, and click the Edit button by hovering on the needed post:
2) Another way can be useful, when some plugins create the fly pages which are only represented by permalink. In such case you can use the admin bar edit option to define content restriction:
In both cases you can find the metabox Site Access Restriction. It looks the same as in Settings → Post Types tab, and it works the same. The difference is - in plugin Settings you define global settings for all posts of chosen type, and in metabox you can configure Access Restriction for specific post that overrides global settings. And here you can also choose the option Follow global options for this post type. So, let's set here the value "21" in the Access denied X days from registration. As a result, this post will be not available for newbie users 7 days longer than other posts that are restricted for 14 days.
When you change the settings don't forget to click the button Update or Publish at the top right to save the changes.
Restricting Definite Categories
Using this plugin you can restrict access not only to some definite post types or to specific posts, but also to the post categories.
It can be done via setting the restriction access to specific URL's on your site. Let's consider this use case on the example of restricting a category about Rock music.
First, to restrict some definite post categories, you need to make sure that your permalinks have the right structure for this. Navigate to Admin Dashboard → Settings → Permalinks.
There you need choose Custom Structure of permalinks and set Available tags in the following consequence: %category%, then %postname%.
As a result, every post will have the following format: your-site.com/category/post
It will help us to restrict all posts that belong to the definite category.
Restricting by URL Filter
To add a URL filter, navigate to Admin Dashboard → CM Site Access Restriction Pro → URL Filters.
Click Add new filter button.
There you can see the field where you can put need URL. You need to enter the exact URL address you want to match without the hostname part. And in our use case we need to add a wildcard * to restrict all posts that belong to this category, like you can see on the screenshot below.
The Access Restriction settings for URLs are the same as in the previous cases and they override global settings. So let's just set here the amount of days in the Access denied X days from registration.
You can add as many URLs for restricting as you need using Add new filter button, and don't forget to click the Save filters button to save them. You can also remove not needed filters using the button Delete.
Following instructions found in the plugin and guides, you should be able to build drip content pages.
Use Case Front-End