2

I'd like to set up an autoresponder based on the fields chosen in the Contact Form 7 form. For instance, I will have the fields of the form change based on the "Job Title" field. This field will have "Job Title 1" "Job Title 2". When the autoresponder is sent, it will only include a message based on the selection of one of the two Job Titles.

Any help would be much appreciated!

Update:

So I tried the suggestion here Conditional auto responder is Contact Form 7.

Here's the code they suggested:

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

}

After trying this, I don't see a response based on the selection of one of the three positions, nor any auto response at all. I'm guessing this will override the Mail 2 function on the CF7 control panel? I've tried it with it checked, and without it checked.

  • 1
    Please let us know what you've tried so far – bendl Aug 28 '17 at 15:08
  • @bendl I updated the OP to show the code that I'm working with right now. Sorry for not explaining more. – artflywheel Aug 29 '17 at 14:51
  • Not a problem! Welcome to Stack Overflow! I suggest you read the [Minimal, Complete and Verifyable](https://stackoverflow.com/help/mcve) page, it will help others help you! – bendl Aug 29 '17 at 14:54

0 Answers0