function UnblockUser::execute

Same name in other branches
  1. 9 core/modules/user/src/Plugin/Action/UnblockUser.php \Drupal\user\Plugin\Action\UnblockUser::execute()
  2. 8.9.x core/modules/user/src/Plugin/Action/UnblockUser.php \Drupal\user\Plugin\Action\UnblockUser::execute()
  3. 10 core/modules/user/src/Plugin/Action/UnblockUser.php \Drupal\user\Plugin\Action\UnblockUser::execute()

Overrides ExecutableInterface::execute

File

core/modules/user/src/Plugin/Action/UnblockUser.php, line 23

Class

UnblockUser
Unblocks a user.

Namespace

Drupal\user\Plugin\Action

Code

public function execute($account = NULL) {
    // Skip unblocking user if they are already unblocked.
    if ($account !== FALSE && $account->isBlocked()) {
        $account->activate();
        $account->save();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.