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.

Back to User Guides

Note: This guide requires:

Introduction

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 user 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.

It follows:


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.

Front-End Examples

The content restriction can be set by the following options:

  1. Specific URL - You can restrict access to specific posts. This can also include URL parameters. 
  2. 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.
  3. 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.
  4. To all posts by type - Using the plugin setting, you can restrict content across all post from a specific type.
  5. 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.

Setting Up

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.

      Example

    • Restrict content with shortcode only - Show all content except those parts that are restricted by the [access] shortcode. Learn more about this shortcode.
  • 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 limit the access a post or page for on 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 the 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 specific date or period of time, we need the following options in the Products section:

  • Access restricted by specific date/time - 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 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 the specific date when the chosen product will be available for users in the Access denied X days from registration. 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.

Result

Restricting With URL Filter

Plugin also support restriction access to specific URL's on your site. This is very useful when you want to prevent access to specific section of plugins which use get params or you want to define only specific pages or post.

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. 

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

Result

End Result

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
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us