public function UserEmailVerification::blockUserAccountById in User email verification 8
Blocks user account by ID.
Parameters
int $uid: User ID.
Overrides UserEmailVerificationInterface::blockUserAccountById
File
- src/
UserEmailVerification.php, line 378
Class
- UserEmailVerification
- User email verification helper service.
Namespace
Drupal\user_email_verificationCode
public function blockUserAccountById($uid) {
$user = $this->entityTypeManager
->getStorage('user')
->load($uid);
// If the account exists and is active, it should be blocked.
if ($user instanceof UserInterface && $user
->isActive()) {
$user
->block()
->save();
if ($this
->isExtendedPeriodEnabled()) {
// If extended verification period is enabled - send Email to user
// with a link which lets user to activate and verify the account
// within defined time period.
$this->mailManager
->mail('user_email_verification', 'verify_extended', $user
->getEmail(), $user
->getPreferredLangcode(), [
'user' => $user,
]);
}
}
}