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

Removes a role from a user account.

Parameters

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

Related topics

File

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

Code

function user_remove_role_action($account, &$context) {
  $role_name = $context['action_info']['role_name'];
  $index = array_search($role_name, $account->roles);
  if ($index !== FALSE) {
    unset($account->roles[$index]);
    $account->save();
  }
}