Membership Pro - BCC Automated Emails to multiple email addresses

Hi All,

To follow up on a previous post, I now need the ability to blind copy the automated emails to multiple email addresses.

The following is the code required to pull this off:

add_filter('ms_view_settings_prepare_email_fields', 'pc_comms_rename_cc', 10, 1);
add_action('ms_model_communication__set_after', 'pc_comms_save_cc', 10, 3);
add_filter('ms_model_communication_send_message_recipients', 'pc_comms_recipients', 10, 3);
add_filter('ms_model_communication_send_message_headers', 'pc_comms_headers', 10, 3);

function pc_comms_rename_cc($fields){
	// Change the name of the cc_enabled checkbox
	$fields['cc_enabled']['title'] = __( 'Send blind copy to Administrator', MS_TEXT_DOMAIN );
	// Change the field type from dropdown to text and make it wider
	$fields['cc_email']['type'] = MS_Helper_Html::INPUT_TYPE_TEXT;
	$fields['cc_email']['class'] = 'ms-comm-subject widefat';
	$fields['cc_email']['field_options'] = null;

return $fields;
}

function pc_comms_save_cc($property, $value, $glob){
	// Check and save the email addresses
	switch ( $property ) {
		case 'cc_email':
			$a = explode(',', $value);
			$good = array();
			foreach ($a as $v){
				$v = trim($v);
				if ( is_email( $v ) ) {
					$good[] = $v;
					}
				}
			$glob->set_field($property, implode(',',$good));
		break;
		}
	}

function pc_comms_recipients($recipients, $invoice, $subscription){
	// Remove the emails from the recipients
	if ( $invoice->cc_enabled ) {
		if(($key = array_search($invoice->cc_email, $recipients)) !== false) {
			unset($recipients[$key]);
			}
		} 

return $recipients;
}

function pc_comms_headers($headers, $invoice, $subscription){
	// Set headers
	$headers = 'From: Membership Wordpress <email@domain.co.uk>'  . "\r\n";
	// Set new bcc emails
	if ( $invoice->cc_enabled ) {
		$headers .= 'Bcc: ' . $invoice->cc_email  . "\r\n";
		} 

return $headers;
}

Hope this helps.
Ian