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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3293435-7-wrong-emails.patch | 1.61 KB | itsruanduplessis |
| #6 | 3293435-6-wrong-emails.patch | 1.62 KB | dbouman |
| #5 | 3293435-4-wrong-mails.patch | 2.11 KB | yivanov |
| #4 | 3293435-4-wrong-mails.patch | 2.11 KB | yivanov |
| email-from-core.txt | 555 bytes | cristiroma |
Issue fork user_registrationpassword-3293435
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:
- 3293435-wrong-emails-sent
changes, plain diff MR !13
- 2.0.x
changes, plain diff MR !1
Comments
Comment #2
cristiroma commentedComment #4
yivanov commentedThanks 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)
Comment #5
yivanov commentedFor 2.x as well
Comment #6
dbouman commentedI 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.
Comment #7
sidgrafix commentedJust ran into this..
+1 for patch 6, I agree with dbouman.
Comment #8
itsruanduplessis commentedRerolled patch #6 for 2.0.2
Comment #11
shivam_tiwari commentedI 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
Comment #12
divyansh.gupta commentedI 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+!
Comment #13
orkutmuratyilmazany chance for merge?
Comment #15
vladimirausThanks everyone for your contributions.
Merged. 🍻
Comment #17
orkutmuratyilmazThanks for the fix too:)