没有现成的功能可以让您为一个帐户向多个电子邮件地址发送电子邮件,但您可以将一个功能挂接到wp_mail
根据收件人地址或主题行进行筛选和检查,并将您的抄送/广播公司添加到该筛选中,例如:
// Add extra contact info fields to user profile page
function extra_contact_info_wpa_134454($contactmethods) {
$contactmethods[\'bcc\'] = \'Email BCC\';
$contactmethods[\'cc\'] = \'Email CC\';
return $contactmethods;
}
add_filter(\'user_contactmethods\', \'extra_contact_info_wpa_134454\');
add_filter(\'wp_mail\',\'add_cc_bcc_to_mail_wpa_134454\');
function add_cc_bcc_to_mail_wpa_134454($args){
//try to get the user id by the "to mail"
$user = get_user_by( \'email\', $args[\'to\'] );
if ($user){
//get ccs if exists
if ( ($cc = get_user_meta( $user->ID, \'cc\', true ) ){
//explode by comma "," to allow multiple cc addresses
foreach ((array)explode(",", $cc) as $email) {
$args[\'headers\'][] = \'Cc: \'.$email;
}
}
if ( ($bcc = get_user_meta( $user->ID, \'bcc\', true ) ){
//explode by comma "," to allow multiple bcc addresses
foreach ((array)explode(",", $bcc) as $email) {
$args[\'headers\'][] = \'Bcc: \'.$email;
}
}
}
return $args;
}
现在,在每次发送邮件时,它都会检查邮件是否属于某个用户,如果属于某个用户,它会检查该用户是否在其个人资料中输入了抄送或密件抄送电子邮件地址,这些地址将添加到该邮件中。