【发布时间】:2021-08-18 08:04:44
【问题描述】:
我正在尝试用高级自定义字段插件中的值替换联系人表单 7 插件中的电子邮件收件人,因为我在每条记录中都有一个动态收件人。我在网上找到了一个函数,但它对我不起作用,表单返回发送错误。
function wpcf7_before_send_mail_function( $contact_form, $abort, $submission ) {
global $post;
$dynamic_email = get_field('form_email',$post->ID); // get your email address...
$properties = $contact_form->get_properties();
$properties['mail']['recipient'] = $dynamic_email;
$contact_form->set_properties($properties);
return $contact_form;
}
add_filter( 'wpcf7_before_send_mail', 'wpcf7_before_send_mail_function', 10, 3 );
也许有一个更简单的函数可以工作,或者我做错了什么?
【问题讨论】: