Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockUser.php

function BlockUser::execute

Overrides ExecutableInterface::execute

File

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

Class

BlockUser
Blocks a user.

Namespace

Drupal\user\Plugin\Action

Code

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();
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal