Currently, a user can be added without an email address (the field is optional). However, as soon as a user receives an email address, the email field becomes required. This leaves things in a sort of halfway state. It seems like one of the following should be true:

  1. It is valid for a user to have no email address. If this is the case, then the field should not be required on user edit. (Otherwise you can't return a user to this state after an address has been entered.)
  2. A user must have an email address defined. If this is the case, then the field should be required on user add also.

I'm not sure which way is preferred, but it would be great if this experience was consistent.

CommentFileSizeAuthor
#11 email_fields.png282.2 KBmlahde

Comments

kevin.dutra created an issue. See original summary.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dpi’s picture

Issue tags: +user email

Confirmed issue on 8.3

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mpp’s picture

Priority: Normal » Major

This seems like a major issue.

alokbhatt’s picture

I am using 8.3.2 and as an Administer, I can see in both the cases, Add and Edit user, email field is not mandatory.
So would Email field be mandatory in both cases or some cases? Please provide detail requirement.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mlahde’s picture

StatusFileSize
new282.2 KB

This is still valid in Drupal 8.5.2, please see "/admin/people/create" and "/user/xxx/edit", where xxx is the user ID.
I attached a screen shot also.

We have a Drupal site where there shouldn't be emails used at all. The users are migrated to the system without email adresses and that works fine. Unfortunately they cannot be edited (for example to change the password or deleted) because the email is a mandatory field. This is a bit contradictory since you can also create a user without an email through UI.

bohemier’s picture

I agree with this inconsistency and am running into the same issue with 8.5.3.

In the meantime I was able to get around this by implementing hook_user_form_form_alter:

  // Unset mail required
  $form['account']['mail']['#required'] = FALSE;
  // Use our own validation
  $form['#validate'][] = '_user_form_validate';

and in

function _user_form_validate($form, &$form_state) {
  // Get all form errors
  $form_errors = $form_state->getErrors();

  // Clear form errors
  $form_state->clearErrors();

  // Remove the error on email
  unset($form_errors['mail']);

  // Re-apply the other form errors
  foreach ($form_errors as $name => $error_message) {
    $form_state->setErrorByName($name, $error_message);
  }
}
gmem’s picture

I wonder how effective a simple checkbox for toggling whether an email is required or not would be, either by removing the required tag or removing the input/validation entirely. This way it would be entirely possible to add and edit users without needing to fill in the email field, since according to #11 the email field doesn't seem to be required in the database itself.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aaronmchale’s picture

Regarding #13 I wonder if we could utilise the existing "required" checkbox that Fields have as a configuration option, as in somehow expose that option for the Email field in the Field UI.

dpi’s picture

Title: User email requirement is inconsistant » User email requirement is inconsistent

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Priority: Major » Normal
Issue tags: -user email +Bug Smash Initiative, +Needs issue summary update, +Novice

Triaged during a BugSmash group triage meeting with myself and darvanen in the thread.

We agree this is Normal priority. And, of course, BC will need to be considered.

This also needs an issue summary update, noting the proposed resolution in #13, see Write an issue summary for an existing issue for guidance. Updating the IS for this issue is suitable for a novice task, adding tag.

quietone’s picture

Priority: Normal » Major
Status: Active » Closed (duplicate)
Issue tags: -Needs issue summary update, -Novice
Related issues: +#286401: Make email not required for a Drupal site account

On further discussion, darvanen found a duplicate, #286401: Make email not required for a Drupal site account. And lendude joined noting that #2227381: Apply formatters and widgets to User base fields 'name' and 'email' is likely the 'root fix'.

Therefor closing this issue as a duplicate.