Admin-created users are incorrectly blocked when "Require email verification (with password)" is enabled

Created on 26 August 2025, about 2 months ago

Problem/Motivation

When the site is configured to allow visitors to register accounts, and the setting "Require email verification when a visitor creates an account" is set to "Require a verification email, but let users set their password directly on the registration form." (with-pass), the user_registrationpassword_form_user_register_form_alter() function sets the default user status to 0 (blocked) both on /user/register and /admin/people/create.

This logic seems correct for anonymous visitors registering accounts, but it also runs when an admin user (or any user with the proper permission) creates a new user from /admin/people/create. In that case, the account should probably not be automatically blocked.
There is even a comment in the user_registrationpassword_form_user_register_form_alter() function that suggests this should not happen:

// When admin users create a user, this does not need to be executed.

However, currently the condition in user_registrationpassword_form_user_register_form_alter() function

if ($user_config->get('register') == UserInterface::REGISTER_VISITORS
    && $config->get('registration') == UserRegistrationPassword::VERIFICATION_PASS
    && $account->isNew()) {
  ...
}

also applies to the admin form, which leads to unexpected behavior.

Steps to reproduce

1. Go to /admin/config/people/accounts and set:
- "Visitors" can register accounts.
- "Require email verification when a visitor creates an account": "Require a verification email, but let users set their password directly on the registration form."
2. Log in as an admin user.
3. Create a new user on /admin/people/create.
3. Observe that the new account is created as blocked (status = 0).

Am I correct in assuming that this is unintended behavior, and that the blocking should not happen for admin-created accounts?

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇭🇺Hungary fox mulder

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

Comments & Activities

Production build 0.71.5 2024