• Resolved WhistlerDev

    (@prd689)


    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)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    I don’t know. Why don’t you comment on the Stack Overflow post?

    Thread Starter WhistlerDev

    (@prd689)

    I just did. The reason I didn’t earlier is because it’s asking for an Answer, which hopefully doesn’t get flagged since it’s not actually an answer. I don’t have enough Comment points to comment on the OP’s post.

    Do you have any suggestions for this problem?

    Thread Starter WhistlerDev

    (@prd689)

    And just like I thought it would, the comment was flagged since it wasn’t an answer.

    Thread Starter WhistlerDev

    (@prd689)

    Never mind on this topic. I’ll mark as resolved, my resolution was purchasing a license to Gravity Forms. This feature and many more are packaged up already.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional Autoresponder based on drop down’ is closed to new replies.