这可以通过连接CF7插件发送通知邮件的过程来实现。该插件提供“wpcf7\\u mail\\u组件”filter 允许您在发送之前修改电子邮件,
add_filter(\'wpcf7_mail_components\',\'add_mgr_mail\',10,3);
function add_mgr_mail($components, $form, $mail_obj){
//if you have several cf7 forms, check this is the right one,
if($form->id() != 1) return $components;
//the components are the in an array...
$components[\'subject\']; //email subject.
$components[\'sender\']; //email sender mail.
$components[\'body\']; //email message body.
$components[\'recipient\']; //email recipient mails.
$components[\'additional_headers\']; //email headers.
$components[\'attachments\']; //email attachments.
//so, to add your mgr email you could do something like:
$post_id = .... //fetch the post ID in which you stored your email.
$mgr_email = get_post_meta($post_id, \'manager_email\',true);
$components[\'body\'] .= PHP_EOL."Manager e-mail:".$mgr_email;
return $components;
}
注:该
$post_id
在上述函数中,表示存储电子邮件的帖子的ID。如果邮件总是一样的,只需在上面的功能中对电子邮件进行硬编码,但是如果您的电子邮件取决于提交的表单,那么您需要识别包含正确电子邮件的帖子,但这完全是另一个问题。