[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 );