如何添加"发送电子邮件副本给自己"联系表格7中的复选框?

时间:2017-03-31 21:42:19

标签: php wordpress contact-form-7

我试图使用以下内容,但我无法使用此代码。

function check_mail_send_contactform($cf7) {
    //get CF7's mail and posted_data objects
    $submission = WPCF7_Submission::get_instance();
    if ( $submission ) {
        $posted_data = $submission->get_posted_data();
    }
    $mail = $cf7->prop( 'mail' );

    if($posted_data['contact_sendmail'][0]) { //if Checkbox checked
        $mail2 = $cf7->prop( 'mail_2' ); //get CF7's mail_2 object
        //now set sender's address to mail2's recipient
        $mail2['recipient'] = $mail['sender'];
        $mail2['active'] = true;
        $cf7->set_properties( array( 'mail_2' => $mail2 ) );
    }
    return $cf7;
}
add_action('wpcf7_before_send_mail','check_mail_send_contactform');

我已经转发了mail_2,似乎设置正确;活动,收件人设置和电子邮件设置w标题等

0 个答案:

没有答案