Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.3 kB
5
Indexable
add_action( 'xoo_el_registration_success', function( $customer_id ){

	$regionFieldID = 'xoo_aff_select_list_3a47e';

	$customerRegion = get_user_meta( $customer_id, $regionFieldID, true );

	//Add multiple email ids separated by comma
	$emails = array(
		'cis-greece-italy' 	=> array( 'firstemail@gmail.com', 'secondemail@gmail.com' ),
		'latam' 			=> array( 'firstemail@gmail.com', 'secondemail@gmail.com' ),
		'Mena' 				=> array( 'firstemail@gmail.com', 'secondemail@gmail.com' ),
		'cee-baltics' 		=> array( 'firstemail@gmail.com', 'secondemail@gmail.com' ),
	);

	$user 			= get_userdata( $customer_id );
	$regionLabel 	= xoo_el()->aff->fields->get_field_value_label( $regionFieldID, $customerRegion ); 

	$content  = '<h3>A new user has signed up:</h3>';
	$content .= '<b>Region:</b> '.$regionLabel.'<br><br>';
	$content .= '<b>Email:</b> '.$user->user_email.'<br><br>';
	$content .= '<b>Name:</b> '. $user->display_name.'<br><br>';

	$sendTo = isset( $emails[ $customerRegion ] ) ? $emails[ $customerRegion ] : '';

	if( !$sendTo || empty( $sendTo ) ) return;

	foreach ( $sendTo as $emailid ) {
		wp_mail(
			$emailid,
			'A new user has signed up - '.$regionLabel,
			$content,
			array( 'Content-Type: text/html; charset=UTF-8' )
		);
	}

} );
Leave a Comment