CM Restrict User Account Access - Use Case - How To Create a User Account That Is Automatically Blocked After X Days


Use Case - How to create a user account that is automatically blocked after X days

Back to User Guides

Note: This guide requires:

Video Use-Case


Introduction

CM Restrict User Account allows you to automatically block or delete user accounts on your site after some period of time, or restrict user accounts by the amount of logins.

Use Case Front-End

The user tries to login when the account is expired:

The user tries to login when the account is not activated yet:

Use Case Assumptions

In this example use case guide we will consider how to create a user account that is automatically blocked after certain period of time. 

We assume that you have already bought the plugin, but not installed it yet.

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: Installation


Creating User Account - Individual Settings

There are two ways how you can restrict user accounts by the time. First way is to set the expiration date for each user. It can be done for already existing user or to the new one. So, let's create a new user. Navigate to Admin Dashboard â†’ Users â†’ All Users â†’ Add New or Admin Dashboard â†’ Users â†’ Add New.

Fill required information about the user:

  • Username
  • Email
  • Password

Then scroll down to the section CM Restrict User Account Access. You can find there two options. We need the option Restrict user by date - choose Yes to enable date restriction.

When the option is enabled, a few new options will appear:

  • Account activation date - Set the time, when the account will be activated. If the user tries to login before that time, he will see the message that his account is not activated yet (you can change the message text in plugin settings).
  • Restrict date - Set the time, when the account will be blocked. If the user tries to login after that time, he will see the message that he doesn't have the access anymore (you can change the message text in plugin settings). Let's set the expiration date 14 days after the account activation.
  • Delete when expire - Enable this option if you want to delete the account when the access time expires. If enabled, one more option will appear:
    • What should be done with content owned by this user - Here you can define, what to do with the user's content:
      • Delete all content
      • Attribute all content to the specific user
      • Use default global setting (default option can be defined in plugin settings).

        We will not enable deletion of the expired account now, let's just block expired account.

When you finished setting restriction for the user, scroll down and click the button Add New User to create the user.

Now get back to the list of all users. You can see restriction dates for each user (if defined) in the column Restrict Date.

Result

The user tries to login when the account is not activated yet:

The user tries to login when the account is expired:

General Settings

There are also some general settings that can be applied for all new registered users. To configure them, navigate to  Admin Dashboard â†’ CM Restrict User Account Access Pro → Settings â†’ General tab.

There are a few sections with options. We will consider only the ones that are relevant to the date restriction feature.

Default settings

The options that we need in this section are:

  • Default value for "Delete user after date" checkbox - If enabled, the checkbox Delete when expire on the user profile editing page will be checked by default. You can check or uncheck this option individually for each user. This prevents accidental expirations and deletions. Let's keep this option disabled now.

  • Login error message (not activated) - You can set the message which appears if the user tries to login when his account is not activated yet.
  • Login error message - You can set the message which appears if the user tries to login when his account is expired.
  • Choose what to do with the content of a deleted user - You can either delete all the content or reassign it to another user with the help of setting below. This option can be overridden individually for each user on the user profile editing page.
  • Pick the user to attribute content to - If you want to attribute all content of deleted user to another user, you should pick the user here. Note: this will take effect only if you choose Attribute all content to another user in the setting above. This choice can be overridden individually for each user on the user profile editing page.

User registration settings

This section defines expiration period for all new registered users. The options are:

  • Enable expire date time after registration - Enable this option to automatically expire accounts after registration.
  • Time period - Input the amount of time (for instance, 30).
  • Time unit - Choose the type of time period if it should be Hour(s) or Day(s) (for instance, 30 days).

Manually triggers

Last section has only one option:

  • Expiration date set for users - Adds an expiration date to all accounts without any expiration date set. Note: It will skip the users which already have expiration date and all admin users.

Examples

User Registration Date Current Date Number of days in this setting Result
Jan 3rd 2022 Jan 1st 2022 2 Account will now expire in Jan 5th 2022
 Jan 5th 2022 Jan 10th 2022 10 Account will be reactivated and expire again in Jan 15th 2022

Notifications

The plugin has a few notifications that can be sent to the admin and user when the account is restricted or deleted.

To configure them, navigate to the Notifications tab. There you can find two sections.

Admin notifications

In this section we need the following options:

  • Admin notification addresses - Write here the list of emails where the admin notifications should be sent. If there is more than one email, they should be separated by comma.
  • Enable admin user reached date notification - Enable this option if you want the admin to receive a notification when the user's account is restricted or deleted.
  • Admin reached date notification subject - Edit the email subject for the admin notification.
  • Admin reached date notification text - Edit the email body for the admin notification. 

User notifications

The options in this section are:

  • Enable user notification - Enable this option if you want the user to receive a notification when his account is restricted or deleted.
  • User notification subject - Edit the email subject for the user notification. 
  • User notification text - Edit the email body for the user notification.

TIP: Shortcodes

Email subject and email body for both notifications accept the following shortcodes for adding dynamic content:

  • [action]  - can be "restricted" or "deleted"
  • [user_name]  - User Name
  • [user_login]  - User Login

Configuration is completed, now click the button Save at the bottom of the page.

Now, each new user that has registered on your site will be blocked in 30 days since the moment of account registration. The user and the admin will be notified when the account gets expired.

End Result

Following instructions found in the plugin and guides, you should be able to create a user account that is automatically blocked after certain period of time. 

Use Case Front-End

The user tries to login when the account is expired:

The user tries to login when the account is not activated yet:


More information about the CM Restrict User Account Access 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.