Site Access Restriction (SAR) - Use Case - How to Limit the Access to Specific Post/Page On Specific Day
Use Case – How to Limit the Access to Specific Post/Page On Specific Day.
- 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 use case guide we will consider how to limit the access to specific posts or pages on specific day or period of time. We will consider the process on the example of restricting the access for WooCommerce products and shop - this process can be applied the same way for any post type or page.
We consider that you have already bought the plugin, but not installed it yet.
- Installing the plugin
- How content restriction works
- Setting up
- Restricting posts, pages and more
- Restricting specific post
- Restricting with URL filter
- 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 posts of a certain 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.
- Access Denied page URL - The page, where the user will be redirected if he tries to access the page which is restricted.
- Login page URL - The page, where the user will be redirected if he is not logged-in and tries to access the page which is restricted. If the user logged-in, but his user role is not allowed to access the page, he will be redirected to the page defined in the previous option. Let's keep this field empty now, as we are not going to restrict the access for logged-in users or by user role in this use case.
- Restriction type - Here you can choose how much of the content is restricted:
- Restrict full content - Restrict all content on the page. Let's choose this option for our example.
- 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.
- 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%.
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.
Restricting Posts, Pages and More
There are a few ways, how you can limit the access to a post or page for a specific date or period of time. Let's start with restricting all posts of a definite type. In our case it will be Products of WooCommerce.
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 general pages and posts. There is a long list of items that you can restrict.
For our use case, to limit the access to products on a specific date or period of time, we need the following options in the Products section:
- Access restricted by specific date/time - The access is allowed only within defined period of time. You need to set start and end dates in the fields From and To. Let's set here the period of time from 1st to 30th November. It means that all WooCommerce product pages will not be available before and after defined period of time.
- 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.
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, posts or other custom post types using a metabox located in each page or post once editing the post.
You can edit posts or pages in two ways.
1) Open the list with products, for example, and click the Edit button by hovering on the needed product:
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 access global options for this post type. So, let's set the specific date when the chosen product will be available for users in the Access restricted by specific date/time. As a result, this post will be not available on any other day except 5th November.
When you change the settings don't forget to click the button Update or Publish at the top right to save the changes.
Restricting With URL Filter
The plugin also supports restricting access to specific URLs on your site. This is very useful when you want to prevent access to specific sections of plugins which use get params or you want to define only specific pages or posts.
To add a URL filter, navigate to Admin Dashboard → CM Site Access Restriction Pro → URL Filters.
Click the Add new filter button.
There you can see the field where you can put needed URL. You need to enter the exact URL address you want to match without the hostname part.
Let's restrict the access to the Shop page.
So, in our use case we need to add /shop/ to the URL field.
The Access Restriction settings for URLs are the same as in the previous cases and they override global settings. So let's set the period of time when this page will be available for users in the Access restricted by specific date/time - from 1st to 30th November.
You can add as many URLs for restricting as you need using the 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 limit the access to specific posts or pages on specific day or period of time.
Use Case Front-End
More information about the Site and Content Restriction WordPress Plugin
Other WordPress products can be found at CreativeMinds WordPress Store
Let us know how we can Improve this Product Documentation Page
To open a Support Ticket visit our support center