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. The former contains the single use link which does not work. (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

When attempting to access the link http://drupal9.localhost/user/reset/7/1656521212/Yq6SA7UIW8xC68lfUOa04At... - it shows "Access denied" because the account is blocked yet (it wasn't yet enabled). (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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cristiroma created an issue. See original summary.

cristiroma’s picture

Issue summary: View changes

yivanov’s picture

StatusFileSize
new2.11 KB

Thanks for fixing this issue. Until it is merged to the module, I am adding it as a patch as well in case anyone needs it like me.
(for 1.x)

yivanov’s picture

StatusFileSize
new2.11 KB

For 2.x as well

dbouman’s picture

StatusFileSize
new1.62 KB

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.

sidgrafix’s picture

Just ran into this..

+1 for patch 6, I agree with dbouman.

itsruanduplessis’s picture

StatusFileSize
new1.61 KB

Rerolled patch #6 for 2.0.2

shivam_tiwari made their first commit to this issue’s fork.

shivam_tiwari’s picture

Status: Active » Needs review

I worked on it. At the time of creating an user by admin account, got error related to this issue: https://www.drupal.org/project/user_registrationpassword/issues/3467248
After fixing that, checked here and it worked fine. Added my changes on MR 13, because previous MR code is outdated. Moving this issue to Needs Review

divyansh.gupta’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed the issue and the MR-13 successfully applied for me and now it is working as expected, also the changes looks good to me thus moving it to RTBC+!

orkutmuratyilmaz’s picture

any chance for merge?

vladimiraus changed the visibility of the branch 2.0.x to hidden.

vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone for your contributions.
Merged. 🍻

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

orkutmuratyilmaz’s picture

Thanks for the fix too:)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.