Skip to content
Snippets Groups Projects

Make the email address field required when creating a new user

1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
@@ -100,7 +100,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#type' => 'email',
'#title' => $this->t('Email address'),
'#description' => $this->t('The email address is not made public. It will only be used if you need to be contacted about your account or for opted-in notifications.'),
'#required' => !(!$account->getEmail() && $user->hasPermission('administer users')),
'#required' => $register || !(!$account->getEmail() && $user->hasPermission('administer users')),
'#default_value' => (!$register ? $account->getEmail() : ''),
'#access' => $account->mail->access('edit'),
];
Loading