Created
August 23, 2017 08:19
-
-
Save wpmudev-sls/2b4163d85eb08a10cc4f9390ffb692d1 to your computer and use it in GitHub Desktop.
[Membership] - Add editors emails to get copy in auto email responses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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