Conditional Autoresponder based on drop down
-
I’m trying to have an autoresponse on form submit sent based on the selection in a drop down menu. If I have two job titles in the drop down, each has been set up to deliver a different set of questions based on the selection. I’d like to be able to send an autoresponse to Job Title 1 if selected, or a different one if Job Title 2 is selected. I’ve tried the following code to create an autoresponse based on a drop down menu:
#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 ); } }
I’ve tried with and without the Mail 2 option selected, but I don’t see any auto response. Am I doing this right? I followed this suggestion
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Conditional Autoresponder based on drop down’ is closed to new replies.