基于联系表格7字段的条件自动回复

时间:2017-08-28 15:06:17

标签: php wordpress forms contact-form-7

我想根据联系表格7表格中选择的字段设置自动回复。例如,我将根据“职务”字段更改表单的字段。该字段将具有“职务1”“职称2”。发送自动回复时,它将仅包含基于两个作业标题之一的选择的消息。

非常感谢任何帮助!

更新

所以我在这里尝试了Conditional auto responder is Contact Form 7的建议。

以下是他们建议的代码:

#hook in to wpcf7_mail_sent - this will happen after form is submitted
add_action( 'wpcf7_mail_sent', 'contact_form_autoresponders' ); 

#our autoresponders function
function contact_form_autoresponders( $contact_form ) {

    if( $contact_form->id==1 ){ #your contact form ID - you can find this in contact form 7 settings

        #retrieve the details of the form/post
        $submission = WPCF7_Submission::get_instance();
        $posted_data = $submission->get_posted_data();                          

        #set autoresponders based on dropdown choice            
        switch( $posted_data['position'] ){ #your dropdown menu field name
            case 'Media Buyer':
            $msg="This is an auto response for Media Buyer";
            break;

            case 'Agency':
            $msg="This is an auto response for Agency";
            break;

            case 'Business Owner':
            $msg="This is an auto response for Business Owner";
            break;

        }

        #mail it to them
        mail( $posted_data['YourEmail'], 'Thanks for your enquiry', $msg );
    }

}

尝试此操作后,我看不到基于三个位置之一的选择的响应,也没有看到任何自动响应。我猜这会覆盖CF7控制面板上的Mail 2功能?我已经检查了它,没有检查它。

0 个答案:

没有答案