WordPress Invitation Code + WordPress Restricted Site Access (SAR) - Use Case - How to Restrict Content Based On User Roles While Allowing Access via Invitation Codes


Use Case - How to Restrict Content Based On User Roles While Allowing Access via Invitation Codes

Back to User Guides

Note: This guide requires:


Introduction

This WordPress Invitation Code plugin allows you to create and sell a series of personalized temporary access codes. Each code grants limited access to a selected page only. When creating a code, you assign it to a post, page, URL, or file. The assigned content will be locked, and visitors will be prompted to enter the code to access it.

WordPress Restricted Site Access is a 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

Example 1: guest users can't access posts, but can access a specific post with the invitation code:

Front-end example 1 - Invitation Code Registration for WordPress
Front-end example 1

Example 2: logged-in users can access posts, but a specific post can be accessed only with the invitation code:

Front-end example 2 - Content Control WordPress
Front-end example 2

Use Case Assumptions

In this example use case guide we will consider how to use the integration between 2 plugins to manage access to your content based on user roles while providing selective access via invitation codes.

We consider that you have already bought the plugins, but not installed them yet. 

It follows:

Installing the Plugin

The process is the same for all CM plugins and add-ons.

CreativeMinds Customer Account Dashboard - Downloads tab
CreativeMinds Customer Account Dashboard
  • 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


Quick Recap

In this use case guide we will focus only on how 2 plugins interact with each other. If you want to learn more about the settings and functionality of each plugin, then please check the following use case guides:

What It Is About

In some cases, you may want to restrict access to content based on user roles, while also providing an alternative access method through invitation codes. This use case demonstrates how to leverage the integration between two plugins: one for controlling access by user roles and the other for providing exclusive access via invitation codes.

For example, you have a website with multiple posts. You want to allow only logged-in users to access most of the content, but for certain posts, you want to create an even more restrictive access model where only users with a valid invitation code can view the content.

Restricting Access To Content Based On User Roles

Let's begin by configuring global access restrictions for specific post types. It can be done using the plugin WordPress Restricted Site Access. Navigate to Admin Dashboard â†’ CM Site Access Restriction Pro → Settings → General tab.

Navigation to the general plugin settings - Page Restriction WordPress
Navigation to the general plugin settings

There's a set of options allowing to define the way the content should be restricted. For this use case, we will select the most basic option: Restrict full content under the Restriction type setting. It means that when a user visits the content he is not allowed, he will not see content - only the message that the content is locked for him.

Choosing the restriction type - WordPress Restrict Content
Choosing the restriction type

TIP

Learn more about other options in this user guide:

Now head to the Post Types tab:

Navigation to post types restriction settings - Content Gate
Navigation to post types restriction settings

This tab allows to configure global restriction for all post types available on your site, including custom post types:

Post types restriction settings - Content Dripping WordPress Plugin
Post types restriction settings

For each post type, you can choose the following restriction:

  • Access not restricted - Access is allowed to all roles including non logged-in users.
  • Access restricted to logged-in users - This means that all users who logged-in on your site can access the content.
    • Access denied X days from user first access - Set the number of days of access expiration. After passing this amount of days the user loses his access to the content after first accessing it.
Access restricted to logged-in users - Tiered Membership
Access restricted to logged-in users
  • Allow only anonymous access - Only non-logged-in users are allowed to view the content.
  • Access restricted by role - Once selected you can specify which roles can access the content.
Access restricted by role - Content Control WordPress
Access restricted by role
  • Access restricted by whitelist - Only users from the whitelist are allowed to view the content.
Access restricted by whitelist - Page Restriction WordPress
Access restricted by whitelist
  • Access restricted by blacklist - Access is allowed to all users except the ones that are defined in the blacklist.
Access restricted by blacklist - WordPress Restrict Content
Access restricted by blacklist
  • 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.
Access restricted by specific date/time - Content Gate
Access restricted by specific date/time
  • Access restricted by joining date - Newly registered users will only be able to see content created on or after the registration date.
  • Access restricted by role and days passed since post creation date - Per each user role you can define the amount of days that should pass after the post is created in order to let the user access its content. Not selected user roles will not be able to access the content. If you don't want to restrict access for specific user roles by the post creation date, you need to select this role and set the value "0". If this option is chosen, then non-logged in users can not access the content of that type. Also, if you don't redirect users to the specific "access denied" page, you can show them a message with the date when they can access the content. You can customize the message: Learn more.
Access restricted by role and days passed since post creation date - Content Dripping WordPress Plugin
Access restricted by role and days passed since post creation date
  • Access denied X days from registration - Access is restricted for users that registered less than X days ago.
  • Restriction type - This option overrides global settings. Choose the view of the message that the user will see when he tries to get access to restricted page:
    • Global settings - This is a default value. You can change it in the General tab of Settings.
    • Restrict full content - Works the same as in global settings.
    • Restrict partially content - Works the same as in global settings.
    • Restrict content with shortcode only - Works the same as an option in global plugin settings.

For our use case we are going to limit the access to all posts on our site - we will allow the access to them only to logged-in users, while non logged-in users (guests) will not have access to posts. So we choose the options Access restricted to logged-in users for Posts post type:

Choosing the option Access restricted to logged-in users - Tiered Membership
Choosing the option Access restricted to logged-in users

Front-end result: a guest user can not access posts, while the logged-in user can:

Front-end result - Content Control WordPress
Front-end result

Learn More

The plugin allows to override global plugin restrictions by setting up a restriction for a specific post or page using a metabox, or create URL filters to add restrictions based on URLs.

Learn more about these methods:

Overriding Global Restrictions With Invitation Codes

Now let's limit access to a certain post by invitation codes using the WordPress Invitation Code plugin.

To create an invitation code, navigate to Admin Dashboard â†’ Invitation Code Content Access → Invitation Codes.

Navigation to invitation codes dashboard - WordPress Content Restriction
Navigation to invitation codes dashboard

Next, click the button Add New Invitation code at the top:

Creating new invitation code - Private Content WordPress Plugin
Creating new invitation code

First, you need to add a code name (it's just for internal usage) and define the code itself. You can either type your own code or generate a random one by clicking the button Generate new:

Adding code name and the code itself - Restrict Content Plugin
Adding code name and the code itself

Then you need to define the restricted content.

You can either choose URL/Page as Blocked Content and specify a URL of the needed page or post:

Restricting specific URL - WordPress Register with Invitation Code
Restricting specific URL

Or choose Posts as Blocked Content and choose the needed post from the list:

Restricting specific post - Portal WordPress Plugin Private Content Per User
Restricting specific post

In both cases you can define multiple URLs or Posts.

More Options

The form also includes additional restriction options, such as usage limits, IP restrictions, activation period, expiration time, and more. We will not consider all these options in this use case guide. You can learn more about all of them in this user guide: WordPress Invitation Code - Creating Codes - Single Code

Other restriction options - Members Plugin Restrict Content
Other restriction options

Once you configured the invitation code, click the button Publish to create it:

Creating the code - Invitation Code Registration for WordPress
Creating the code

The same way we can create multiple codes:

Examples of created codes - WordPress Content Restriction
Examples of created codes

When editing a post or page, you can see a list of all invitation codes related to it in the metabox Matching Invitation Codes:

Reviewing codes related to the post - Private Content WordPress Plugin
Reviewing codes related to the post

Once at least one invitation code is created for a post by the WordPress Invitation Code plugin, all restrictions that are set up for this post by the WordPress Restricted Site Access plugin will be ignored. So the post will be accessible only by users that have invitation codes no matter which user roles they have, while other posts will still be restricted based on the user role.

Front-end result 1: guest users can't access posts, but can access a specific post with the invitation code:

Front-end example 1 - Restrict Content Plugin
Front-end example 1

Front-end result 2: logged-in users can access posts, but a specific post can be accessed only with the invitation code:

Front-end example 2 - WordPress Register with Invitation Code
Front-end example 2

End Result

Following instructions found in the plugin and guides, you should be able to use the integration between 2 plugins to manage access to your content based on user roles while providing selective access via invitation codes.

Use Case Front-End

Example 1: guest users can't access posts, but can access a specific post with the invitation code:

Front-end example 1 - Portal WordPress Plugin Private Content Per User
Front-end example 1

Example 2: logged-in users can access posts, but a specific post can be accessed only with the invitation code:

Front-end example 2 -
Front-end example 2

More information about the WordPress Invitation Code 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.