You are here

function user_expire_expire_users in User Expire 8

Same name and namespace in other branches
  1. 7 user_expire.module \user_expire_expire_users()

Expire a group of users.

Parameters

array $accounts: A set of user objects to expire.

3 calls to user_expire_expire_users()
UserExpireTest::testUserExpire in tests/src/Functional/UserExpireTest.php
Tests user expiration functionality.
user_expire_expire_user in ./user_expire.module
Expire a single user.
user_expire_process_per_user_expiration in ./user_expire.module
Expires users who have an expiration that has passed.

File

./user_expire.module, line 255
Main module file for User expire module.

Code

function user_expire_expire_users(array $accounts) {
  foreach ($accounts as $account) {
    if ($account) {

      // Block user's account.
      $account
        ->block();
      \Drupal::entityTypeManager()
        ->getStorage('user')
        ->save($account);

      // Remove current expiration time.
      user_expire_set_expiration($account);

      // Log notification to watchdog.
      \Drupal::logger('user_expire')
        ->info('User %name has expired.', [
        '%name' => $account
          ->getAccountName(),
      ]);
    }
  }
}