Expiring user accounts based on role.

Last updated on
4 February 2025

Key terms:

  • Inactivity:
    • The amount of time a user has not logged into the site. After this time, the account may be expired.
  • Expiration:
    • When a user account is blocked on a specific date, or after the specified amount of time due to inactivity. Blocked users are unable to log in or interact with the site.

Configuration Instructions:

  1. Install and Enable the Module:

    • Ensure that the User Expire module is installed and enabled on your Drupal site.
  2. Access the Configuration Page:

    • Navigate to Configuration » People » User Expire Settings (/admin/config/people/user-expire)
  3. Consult the Time Reference Table:

    • Use the provided table as a guide. It lists common time increments (e.g., 1 Hour = 3600 seconds, 1 Day = 86400 seconds) so you can determine the correct number of seconds to enter for each role.

  4. Configure Expiration Settings by Role:

    • In the Account expiration settings by role fieldset, you’ll see a list of user roles (excluding the anonymous role).
    • For each role, enter the number of seconds of inactivity before the account should expire.
    • Enter “0” for any role where you do not want to enforce automatic expiration.
  5. Set Up Expiration Warning Emails (Optional):

    • In the Account expiration warning settings fieldset, choose whether to send warning emails by checking the “Send account expiration warning emails” option.
    • If enabled, configure:
      • Frequency: How often warning emails are sent (in seconds).
      • Offset: How far in advance (in seconds) to begin sending warnings before an account expires.
    • Customize the email subject and body using the provided text fields. Tokens are available to personalize the message.
  6. Save Your Configuration:

    • Once all fields are set to your desired values, click “Save” to update the settings.
  7. Ensure Cron Is Running:

    • Since the module relies on Drupal’s cron to process inactivity checks and send emails, verify that cron is configured to run regularly.
    • (For more details on setting up cron, refer to Drupal’s Cron Documentation.)
  8. Test the Configuration:

    • Use a test account with one of the targeted roles to ensure that the expiration is applied as expected.
    • Check that notifications (if enabled) are sent and that the account is blocked or otherwise disabled upon expiration.

By following these steps, you can automate the process of expiring user accounts based on their roles, helping to enforce your site's user management policies.

Help improve this page

Page status: No known problems

You can: