function BlockUser::execute
Same name in other branches
- 9 core/modules/user/src/Plugin/Action/BlockUser.php \Drupal\user\Plugin\Action\BlockUser::execute()
- 10 core/modules/user/src/Plugin/Action/BlockUser.php \Drupal\user\Plugin\Action\BlockUser::execute()
- 11.x core/modules/user/src/Plugin/Action/BlockUser.php \Drupal\user\Plugin\Action\BlockUser::execute()
Overrides ExecutableInterface::execute
File
-
core/
modules/ user/ src/ Plugin/ Action/ BlockUser.php, line 22
Class
- BlockUser
- Blocks a user.
Namespace
Drupal\user\Plugin\ActionCode
public function execute($account = NULL) {
// Skip blocking user if they are already blocked.
if ($account !== FALSE && $account->isActive()) {
// For efficiency manually save the original account before applying any
// changes.
$account->original = clone $account;
$account->block();
$account->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.