Wrong emails sent when accounts are manually created from admin

Created on 29 June 2022, over 2 years ago
Updated 29 June 2023, over 1 year ago

Problem/Motivation

When administrators manually create new accounts from /admin/people/create and:

1. Unchecks "Notify user of new account" the system still sends an welcome email to the new account owner.
2. Checks "Notify user of new account" - Two emails are sent: drupal core default welcome mail and another mail from the module. (only if account created is blocked)

Steps to reproduce

1. Setup a new clean Drupal 9 website
2. Install and configure instance to send emails (i.e mailsystem + smtp modules)
3. Install and configure user_registrationpassword module. In /admin/config/people/accounts configure option "Require a verification email, but let users set their password directly on the registration form."

Case #1 - Manually create a new account and uncheck "Notify user of new account".

Expected outcome: There shouldn't be any email sent
Actual outcome: The system sends the welcome email

See email-from-module.txt

Case #2 - Manually create a new account and check "Notify user of new account".

Two emails are sent:

1) From module (email shown above)
2) From Drupal core:

See email-from-core.txt

(if newly created account is blocked which doesn't make sense)

Proposed resolution

The module should check the field 'notify' is present and enabled in the form and if

1) unchecked should not send an email at all - it assumes the administrator will use other means to notify the user
2) checked should only send the email from the module and not the email sent by core

Remaining tasks

Implement suggested fix. It affects both 1.x and 2.x branches.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡·πŸ‡΄Romania cristiroma

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States dbouman

    I tested this patch and while it did prevent a second email, the issue was that when an admin creates an account and selects to notify the user, the email that gets sent out is not the correct email. It should be sending out the core email "Welcome (new user created by administrator)", but instead it is sending out the email generated by this module which at least in my case because we have email verification turned on contains a broken link.

    I've attached the 2.x patch that worked for me, it sends out the user_registrationpassword_mail_notify if the account was not created by an administrator. If the account was created by an administrator it let's core figure out whether or not to send the core welcome email.

  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix

    Just ran into this..

    +1 for patch 6, I agree with dbouman.

  • πŸ‡ΏπŸ‡¦South Africa itsruanduplessis

    Rerolled patch for 2.0.2

Production build 0.71.5 2024