public function deleteUser($username) {
    $users = \Drupal::entityQuery('user')
      ->condition("name", $username)
      ->execute();

    /** @var \Drupal\user\Entity\User $users */
    $users = User::loadMultiple($users);
    foreach ($users as $user) {
      $user->delete();
    }
  }
public function deleteUser($username) {
    $users = \Drupal::entityQuery('user')
      ->condition("name", $username)
      ->execute();

    /** @var \Drupal\user\Entity\User $users */
    $users = User::loadMultiple($users);
    foreach ($users as $user) {
      $user->delete();
    }
  }
public function deleteUser ( $ username ) { $ users = \ Drupal :: entityQuery ( 'user' ) -> condition ( "name" , $ username ) -> execute ( ) ; /** @var \Drupal\user\Entity\User $users */ $ users = User :: loadMultiple ( $ users ) ; foreach ( $ users as $ user ) { $ user -> delete ( ) ; } }
Deletes user by username.

@param string $username
Username.
Deletes user by username .