1 user.actions.inc user_block_user_action(User $account, &$context)

Blocks a specific user account.

Parameters

User $account: The user entity whose account will be blocked.

Related topics

File

core/modules/user/user.actions.inc, line 15
Action callbacks for User module.

Code

function user_block_user_action(User $account, &$context) {
  if ($account->status == 1) {
    $account->status = 0;
    $account->save();
  }
}