Email is no longer required to create a user

Created on 5 September 2024, 8 months ago
Updated 13 September 2024, 7 months ago

Problem/Motivation

It is no longer required to have a valid email to create a user in Drupal.

Steps to reproduce

Use the create user action : email is required.

Proposed resolution

In namespace Drupal\eca_user\Plugin\Action file NewUser.php
1 - delete required attribute (line 61)
2 - delete mail validation (lines 99 to 101).

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Closed: works as designed

Version

2.1

Component

Code

Created by

🇫🇷France eme

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @eme
  • 🇩🇪Germany jurgenhaas Gottmadingen

    It is no longer required to have a valid email to create a user in Drupal.

    Are you sure? Is there a change record available which explains that significant change?

    Actually, looking into the latest code of Drupal 10, the base field definition of the mail field still has a constraint for a required user mail:

        $fields['mail'] = BaseFieldDefinition::create('email')
          ->setLabel(t('Email'))
          ->setDescription(t('The email of this user.'))
          ->setDefaultValue('')
          ->addConstraint('UserMailUnique')
          ->addConstraint('UserMailRequired')
          ->addConstraint('ProtectedUserField');
    
  • 🇫🇷France eme

    On a fresh Drupal 11 install, as you can see on the attachment, the email field is no longer required.

  • Status changed to Closed: works as designed 7 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I've done further research and the current situation is the same as it has always been since Drupal 8. The mail field is still required, but there is an exception that the administrator is allowed to edit and delete users without an email address. This has been allowed to prevent missing email addresses from migrating users into Drupal. In that scenario, such records need to be editable to fix them.

    The fact that an administrator can not only edit and delete such users but also create new ones without an email is considered an unintentional side-effect and needs to be fixed in Drupal core.

    If you create a new user without being an admin, e.g. by using the register account form, then you can see that the email field is marked required.

    A discussion about this topic can also be found with more details at https://drupal.slack.com/archives/C1BMUQ9U6/p1726131601768479

Production build 0.71.5 2024