Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Created August 23, 2017 08:19
Show Gist options
  • Save wpmudev-sls/2b4163d85eb08a10cc4f9390ffb692d1 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/2b4163d85eb08a10cc4f9390ffb692d1 to your computer and use it in GitHub Desktop.
[Membership] - Add editors emails to get copy in auto email responses
<?php
/*
Plugin Name: [Membership] add editors in auto emails
Plugin URI: https://premium.wpmudev.org/
Description: Adds editors emails in the "Send copy to Administrator"
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
add_filter( 'ms_view_settings_prepare_email_fields', function( $fields ){
$admin_emails = $fields['cc_email']['field_options'];
$editor_emails = array();
$args = array(
'role' => 'editor',
'fields' => array( 'ID', 'user_email' ),
);
$wp_user_search = new WP_User_Query( $args );
$users = $wp_user_search->get_results();
if ( ! empty ($users ) ) {
foreach ( $users as $user ) {
$editor_emails[ $user->user_email ] = $user->user_email;
}
}
$fields['cc_email']['field_options'] = array_merge( $admin_emails, $editor_emails );
return $fields;
}, 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment