Role and User Permissions Auto-Expire

User Role Editor Pro · Add-on documentation

The User Role Auto-Expire add-on automatically revokes a role from users when the expiration date set for that role is reached. You can set one expiration date for an entire role, or a separate date for a role assigned to one specific user.

Applies to User Role Editor Pro 4.68 and later.

Temporary access is common: a contractor needs Editor access for the duration of a project, a seasonal employee needs a shop role until the end of the month, or a trial user should lose an elevated role after a fixed period. Removing such roles by hand is easy to forget.

With the User Role Auto-Expire module, the role is removed by a WordPress cron worker as soon as its date and time pass. Optionally, the user can be moved to a fallback role at the same moment, so they keep a basic level of access instead of ending up with no role at all.

Expiration can be configured at two levels:

  • Role-level expiration — one rule for a role. It applies to every user who has that role when the rule is processed.
  • User-level expiration — one rule for a role of one specific user. This is useful when the same role has different lifetimes for different people.

Both levels use the same date and time picker and the same two actions: revoke the role completely or replace it with another role.

Activate the add-on

Go to Settings → User Role Editor and open the Additional Modules tab. Turn on Activate User Role Auto Expire module and click Save.

The Activate User Role Auto Expire module checkbox at the Additional Modules tab of the User Role Editor settings
Activate the User Role Auto Expire module at Settings → User Role Editor → Additional Modules.

Once the module is active, the Auto-Expire button is added to the User Role Editor toolbar at Users → User Role Editor. It appears directly after the Posts View button.

Set an expiration date for a role

  1. Open Users → User Role Editor and select the role you want to expire.
  2. Click the Auto-Expire button in the toolbar on the right.
  3. Configure the expiration in the dialog and click Update.
The Auto-Expire button in the User Role Editor toolbar
The Auto-Expire button in the User Role Editor toolbar.

The dialog contains the following settings:

  • Enable automatic expiration for this role — the master switch for the rule. While it is off, the date and action fields are disabled.
  • Expiration Date & Time — the moment when the role should be revoked. The date and time are interpreted in the site time zone; the current UTC offset is shown next to the fields.
  • Action After Expiration — choose Revoke current role completely to remove the role, or Reassign to another role to give the user a fallback role instead.
  • Fallback role — the role to assign when Reassign to another role is selected. The expiring role itself and the Administrator role are never offered.
  • Preview — a plain-language summary of what will happen, updated as you change the date, time and action.
The Auto-Expire dialog for the Editor role, configured to reassign users to the Contributor role on 31 December 2026 at 23:59
An expiration rule for the Editor role: on 31 December 2026 the role is replaced with Contributor for all users who have it.

After you click Update, the rule is stored for the selected role. To change the date or the action, open the dialog again, update the values and click Update. To remove the rule, clear Enable automatic expiration for this role and click Update.

A role-level rule is a one-time rule. After it has been applied to all users of the role, the rule is removed automatically. To expire the role again later, set a new date.

Set an expiration date for one user

Open Users → All Users and edit the user. Scroll down to the User Role Editor – Assigned Roles & Expiration section.

The section replaces the free plugin’s “Other Roles” block and lists every role assigned to the user:

  • Primary Role — synchronized with the top WordPress Role dropdown. Tick Set expiration for <role> below the dropdown to configure the date and action for the primary role.
  • Other Roles — add a role with + Add additional role…. Every added role gets its own Set expiration for <role> block, so different roles of the same user can expire on different dates.

For each role, choose the date and time, then select either Revoke this role or Replace with: and pick a fallback role. Click Update User to save the profile.

The Assigned Roles and Expiration section on the user profile page, with an expiration configured for the Editor role and an expiration block for another role
Per-user expiration on the profile page: an expiration is set for the Editor role, which will be replaced with Subscriber; the other role has its own expiration block.

When the primary role has a saved expiration, a badge such as Expires December 31, 2026 18:00 – Edit is shown next to the top WordPress Role dropdown. Clicking the badge scrolls to the expiration section.

Set expiration while granting roles

The same controls are available when roles are granted in bulk. On Users → All Users, select one or more users, click Grant Roles, and set the primary role and any additional roles. Every role row except Administrator has its own Set expiration date checkbox, so an expiration can be attached to the roles granted by this operation. Expiration values are validated before any role is granted, and the dialog stays open if a correction is needed.

The Grant Roles dialog with a Set expiration date checkbox for the primary role and for each additional role
The Grant Roles dialog: an expiration can be set for the primary role and for every additional role.

The Without role dialog on the same page includes a Set expiration for the new role block as well. It lets you assign an expiration date at the moment users without a role are moved to a new role.

What happens when the expiration date is reached

The add-on uses WordPress cron to check for due rules every hour:

  • Role-level rules are processed by the ure_role_expiration_check_event event.
  • User-level rules are processed by the ure_user_role_expiration_check_event event.

When a rule is due, the worker removes the expiring role from the affected user. If the rule has a valid fallback role, the fallback role is assigned and the expiring role is removed. The user keeps all capabilities granted by their other roles — only the expiring role is touched.

For a user-level rule, if removing the role leaves the user with no role on the site, the add-on assigns the site’s default role, so the account is not left without any role at all. This fallback can be changed with the ure_role_auto_expire_empty_roles_fallback filter.

Both role-level and user-level rules are one-time rules: each rule is removed from storage after it has been applied.

Role-level rules and the default role. The automatic default-role fallback applies to per-user rules only. If a role-level rule has no fallback role and the expiring role is a user’s only role, that user will be left with no role on the site. When users may not have another role, configure a fallback role for role-level rules.

Expirations are processed in small batches (200 users per batch with a 15-second time budget by default). If a site has a large number of affected users, the worker schedules a follow-up event and continues from where it stopped, instead of trying to process everybody in a single request.

Good to know

  • The Administrator role never expires. It cannot be selected as the expiring role, and it cannot be used as a fallback role. This prevents an accidental lockout of the site administrators.
  • A fallback role must be different from the expiring role. It must also exist and be assignable by the user who saves the rule.
  • Dates use the site time zone. The dialog displays the current UTC offset, for example (UTC+00:00), so you can verify how the date will be interpreted.
  • WP-Cron is traffic-driven. On a low-traffic site the hourly check may run later than the exact expiration minute. If exact timing matters, configure a real server cron job that calls wp cron event run --due-now, or run the due events from your hosting control panel.
  • Rules follow the role, not the user, at the role level. A role-level rule applies to every user who has the role when the worker processes it. Use per-user rules when only one person should lose the role.
  • On a multisite network rules are stored and processed per site. Configure an expiration on each site where the role should expire.
  • Deleted roles. If a role is deleted, its stored rules are ignored and removed at the next run. If a fallback role is deleted, the expiring role is revoked completely when the rule runs.
  • No email notifications. The add-on only changes roles; it does not email the affected user. Use a separate notification plugin if users should be warned before access ends.
  • A user cannot set or change the expiration date for their own roles. Expirations are managed by an administrator or by another user who has the required permissions for that account.
  • Access to the add-on is controlled by the ure_role_auto_expire capability. It is part of the User Role Editor capability set and is enabled for administrators by default; you can grant it to another role with User Role Editor if a site manager should maintain expirations without full administrator access. Managing expirations on the user profile or in the Grant Roles dialog also requires the standard promote_users capability and permission to edit the target account.

Technical details

Role-level rules are stored in the ure_role_expiration_rules option. User-level rules are stored in the _user_role_expirations user meta field. Both use the same structure, keyed by role ID:

{
  "editor": {
    "expires_at": 1798761599,
    "fallback_role": "contributor"
  },
  "temporary_vendor": {
    "expires_at": 1798675200,
    "fallback_role": "none"
  }
}

expires_at is a UTC timestamp. fallback_role is either a role ID or none when the role should be revoked without a replacement.

Hook or filter Purpose
ure_role_expiration_check_event Hourly cron event that processes role-level rules.
ure_user_role_expiration_check_event Hourly cron event that processes user-level rules.
ure_role_expiration_batch_event
ure_user_role_expiration_batch_event
Follow-up single events that continue a large batch after 10 seconds.
ure_role_expiration_batch_size
ure_user_role_expiration_batch_size
Number of users processed per batch. Default: 200.
ure_role_expiration_time_budget
ure_user_role_expiration_time_budget
Time budget for one batch, in seconds. Default: 15.
ure_role_auto_expire_empty_roles_fallback Default role assigned by the per-user worker when a revoked role leaves the user with no role. Receives the default role and the user ID.

Expiration rules are applied with the regular WordPress role API (WP_User::remove_role() and WP_User::add_role()), so role changes made by the worker are visible to every plugin that reads user roles.