Problem/Motivation
User mail notifications are triggered differently:
'register_*'e-mails are triggered by the form creating the user,'status_activated', and'status_blocked'e-mail are triggered by the User Entity itself inUser::postSave.
Beyond being obscurely inconsistent:
You need to choose to also trigger a mail in code when you programatically create an active user; but you always get a mail trigger when you change the status
[At least not without changing the configuration user_settings:status_* values]
It also means you can't programatically and silently change the status of an existing user, unlike creating a new active user; and it means you couldn't add the option to not notify the user on an admin form.
Proposed resolution
Move the trigger out of User::postSave and put it on forms, actions, as appropriate.
Or add some other switch to make it easier not to trigger the mail.
Remaining tasks
Decide which to do.
Do it.
User interface changes
None, but facilitates making optional notification should someone want to do it in contrib.
API changes
The first option (moving out of postSave) would require parties relying on API to add notification to their code.
Data model changes
None.
Comments
Comment #15
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #17
smustgrave commentedWanted to bump 1 more time.
Comment #18
danielvezaIMO the emails being sent in
::postSavemakes sense, if you have it configured for users to recieve emails on status changes, then they should recieve emails, regardless of how the actual change is done.If you wanted to block the emails, I'm pretty sure you'd be able to do this with contrib or a custom module that either swaps out the
Userclass or withhook_mail_alter.There has also been no updates in around 10 years, so it's time to close this one.
Thanks!