You are here

public function UserEmailVerification::deleteUserAccountById in User email verification 8

Delete user account by ID.

Parameters

int $uid: User ID.

Overrides UserEmailVerificationInterface::deleteUserAccountById

File

src/UserEmailVerification.php, line 464

Class

UserEmailVerification
User email verification helper service.

Namespace

Drupal\user_email_verification

Code

public function deleteUserAccountById($uid) {
  $user = $this->entityTypeManager
    ->getStorage('user')
    ->load($uid);
  if ($user instanceof UserInterface) {

    // Notify account about cancellation.
    _user_mail_notify('status_canceled', $user);

    // Init user cancel process.
    user_cancel([], $user
      ->id(), $this->configUserSettings
      ->get('cancel_method'));

    // user_cancel() initiates a batch process. Run it manually.
    $batch =& batch_get();
    $batch['progressive'] = FALSE;
    batch_process();
  }
}