WordPress.org

Make WordPress Core

Opened 10 years ago

Last modified 6 months ago

#10726 reopened enhancement

Admin notifications for more than 1 email

Reported by: novasource Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8.4
Component: Administration Keywords:
Focuses: Cc:
PR Number:

Description

Please allow admin notifications to go to more than 1 email address. It could be as simple as allowing a comma-separated list.

Better yet, allow sending admin notifications to all people in the administrators role.

Change History (27)

#1 @scribu
10 years ago

  • Milestone changed from Unassigned to Future Release

#2 @cnorris23
10 years ago

This has already been attempted before in #3969, and it was closed as won't fix. Mark Jaquith said it would be a big patch (and it would), and suggested that one set up an email address that forwards to all the admins (see comment 4). That being said, making the admin email filterable, should be a fairly easy/small patch, and would allow you to write a plugin to create this functionality.

#3 @nacin
10 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

If anything we'd eventually refactor the admin email aspect in another direction and perhaps tie it to an account (or accounts). This is a source of confusion often. Closing as wontfix as had previously been done.

#4 @westi
9 years ago

  • Cc westi added
  • Milestone set to Future Release
  • Resolution wontfix deleted
  • Status changed from closed to reopened

I think we should re-consider this.

Ideally the option should go and we should send notifications to people based on caps/roles rather than a seconded hidden email address which might not be up-to-date

#5 follow-up: @nacin
9 years ago

This ticket proposed a comma-separated list. I closed this due to a few other tickets proposing the opposite direction (which is what you're suggesting be considered), such as an owner role or some other rework that moves away from the option and toward users. Problem is, now I can't find a ticket now.

#6 in reply to: ↑ 5 ; follow-up: @RanYanivHartstein
9 years ago

Replying to nacin:

This ticket proposed a comma-separated list. I closed this due to a few other tickets proposing the opposite direction (which is what you're suggesting be considered), such as an owner role or some other rework that moves away from the option and toward users. Problem is, now I can't find a ticket now.

I reopened this as a new ticket in #16481

#7 in reply to: ↑ 6 @jane
8 years ago

Replying to RanYanivHartstein:

I reopened this as a new ticket in #16481

Seems like 16481 is just asking to remove the email on General Settings, not to create a new 'owner' role.

#8 @seancojr
8 years ago

  • Cc seancojr added

#9 @lightningspirit
8 years ago

  • Cc lightningspirit@… added

#10 @TheAdityaJain
7 years ago

  • Cc mail@… added

#11 @arippberger
6 years ago

  • Cc arippberger added

#12 @mau
6 years ago

  • Cc ngomau@… added

#13 in reply to: ↑ description @digabyte
6 years ago

FOUR. YEARS. AGO.

For more than four years people have been asking for this... many, many people. How difficult can it be to allow a comma separated list for admin notification in the general settings?

Forcing a user to setup a dedicated admin e-mail account outside of WP with filters and forwarding is ridiculous when a simply comma separated list is all it takes to address the issue.

The first response to the original post states: "Mark Jaquith said it would be a big patch (and it would)" How in the world is a comma separated list a big patch? Perhaps the secondary suggestion of allowing all admins to receive admin notification is a big patch, but if so many people are requesting this functionality, isn't it just lazy to say "that's a big patch?"

I'm not necessarily advocating admin notification for all admins (though, that *does* seem to make perfect sense), but simply adding comma separated list functionality to admin notification should be addressed in the WP core; it should have been addressed years ago.

#14 @supersuphot
6 years ago

Wish to have this feature too

#15 follow-up: @mordauk
6 years ago

I do really like the idea of eventually moving away from a predefined email option, but what's the harm in allowing a comma delineated list of addresses? Seems the only thing we'd have to do is modify the way the option is sanitized so as to not strip out commans when multiple email addresses are detected.

#16 @mordauk
6 years ago

I will happily write a patch for this if we can consider it again.

#17 in reply to: ↑ 15 ; follow-up: @rmccue
6 years ago

Replying to mordauk:

Seems the only thing we'd have to do is modify the way the option is sanitized so as to not strip out commans when multiple email addresses are detected.

FWIW, this is pretty easy: array_filter( explode( ',', $email ), 'is_email' )

#18 in reply to: ↑ 17 @mordauk
6 years ago

Replying to rmccue:

Replying to mordauk:

Seems the only thing we'd have to do is modify the way the option is sanitized so as to not strip out commans when multiple email addresses are detected.

FWIW, this is pretty easy: array_filter( explode( ',', $email ), 'is_email' )

Yes. Why are we not allowing this? I fully understand providing a better UI for multiple emails is much more involved, but I haven't seen a reason why we can't support a comma separated list?

#19 follow-up: @nacin
6 years ago

Anyone using get_option( 'admin_email' ) and expecting a single email, versus a comma-separated list or an array, would cause breakage. Hence the desire to go bigger or not do anything at all.

#20 in reply to: ↑ 19 @mordauk
6 years ago

Replying to nacin:

Anyone using get_option( 'admin_email' ) and expecting a single email, versus a comma-separated list or an array, would cause breakage. Hence the desire to go bigger or not do anything at all.

Ah, hadn't thought of that.

#21 follow-up: @shiroamada
6 years ago

5 years.... any plugin to resolve it? I need multiple admin email to received notification

#22 in reply to: ↑ 21 @nmarks
5 years ago

Replying to shiroamada:

5 years.... any plugin to resolve it? I need multiple admin email to received notification

https://wordpress.org/plugins/cc-admin-emails/

#23 @wbdesigner
5 years ago

Why not do a cc in wordpress that way the emails come from one address but multiple admins can get a notification.
The plugin cc admin emails is a great idea. I'm having trouble making it work but the idea is perfect.
http://wordpress.org/plugins/cc-admin-emails/

This ticket was mentioned in Slack in #core by sergey. View the logs.


4 years ago

#25 @dshanske
4 years ago

I would suggest moving the notification function into the user settings by adding a per administrator role setting. The admin_email setting would remain a single email for backward compatibility.

#26 @tripflex
4 years ago

Whenever I wanted to do something like this it was as easy as filtering wp_mail, checking if to was set to the same thing as the value in admin_email and then adding any additional ones I want, and returning back to wp_mail

Only thing missing would be check for admin email if to is an array, but I have yet to see a case of that where the plugin/theme didn't have its own method of adding additional emails.

I'm going to leave this here but I just realized that this only checks the TO and has no way to tell if it's actually an admin email ... so say the admin_email is the same as your user account, you request password reset ... it will send to those additional emails as well --- sorry about that

add_filter( 'wp_mail', 'my_custom_to_admin_emails' );

/**
* Filter WP_Mail Function to Add Multiple Admin Emails
*
*
*
* @param array $args A compacted array of wp_mail() arguments, including the "to" email,
*                    subject, message, headers, and attachments values.
*
* @return array
*/
function my_custom_to_admin_emails( $args ) {

    // This assumes that admin emails are sent with only the admin email
    // used in the to argument.
    if( is_array( $args['to'] ) ) return $args;

    $admin_email = get_option( 'admin_email' );

    // Check if admin email is in string, as plugins/themes could have changed format (ie. Administrator <admin@domain.com> )
    if( strpos( $args['to'], $admin_email ) !== FALSE ){

        /**
        * Set the to key value to an array of emails, including original admin email
        *
        * All email addresses supplied to wp_mail() as the $to parameter must comply with RFC 2822. Some valid examples:
        * user@example.com
        * User <user@example.com>
        */
        $args['to'] = array( $args['to'], 'user@example.com', 'User <user@example.com>' );
    }

    return $args;
}

Just thought I would add this here in case others come looking for other solutions.

Last edited 4 years ago by tripflex (previous) (diff)

This ticket was mentioned in Slack in #core by tripflex. View the logs.


4 years ago

Note: See TracTickets for help on using tickets.