Условный автоответчик – Контактная форма 7

У меня есть две версии автоответчика, которые я бы хотел отправить на основе того, что пользователь выбрал из раскрывающегося списка. Поэтому, если пользователь выбрал Калифорнию из раскрывающегося списка, он получит автоответчик 1, и если пользователь выбрал Техас, они получат автоответчик 2. Есть ли способ сделать это?

#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 ); } } 

Где именно должен быть добавлен этот код?

перейдите в wpcf7_mail_sent – это произойдет после отправки формы

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 ); } 

}