我有两个版本的自动回复器,我想根据用户从下拉字段中选择的内容发送出去。因此,如果用户从下拉列表中选择加利福尼亚州,他们将获得自动回复1,如果用户选择德克萨斯州,他们将获得自动回复2.有没有办法做到这一点?
答案 0 :(得分:1)
这段代码到底应该添加到哪里?
add_action(' wpcf7_mail_sent',' contact_form_autoresponders');
function contact_form_autoresponders($ contact_form){
if( $contact_form->id==1234 ){ #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['location'] ){ #your dropdown menu field name
case 'California':
$msg="California email body goes here";
break;
case 'Texas':
$msg="Texas email body goes here";
break;
}
#mail it to them
mail( $posted_data['your-email'], 'Thanks for your enquiry', $msg );
}
}
答案 1 :(得分:0)
添加functions.php -
#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==1234 ){ #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['location'] ){ #your dropdown menu field name
case 'California':
$msg="California email body goes here";
break;
case 'Texas':
$msg="Texas email body goes here";
break;
}
#mail it to them
mail( $posted_data['your-email'], 'Thanks for your enquiry', $msg );
}
}