• Hey all,

    I have an event registration form that has a required dropdown with timezone values.

    When the user submits the form I want to send them an email with times of the event but the information sent back is dependant on the value of the dropdown.

    So for example in the email body we need something like

    if($timezone == 'GMT'){
    add GMT times to body of email
    }
    if($timezone == 'PST'){
    add PST times to body of email
    }

    I have been trying to use the following function

    add_action( 'wpcf7_mail_sent', 'my_wpcf7_mail_sent_function' );
    function my_wpcf7_mail_sent_function( $contact_form ) {
         $title = $contact_form->title;
         $submission = WPCF7_Submission::get_instance();
    
         if ( $submission ) {
             $posted_data = $submission->get_posted_data();
         }
         $firstName = $posted_data['your-name'];
         echo 'aaaa'.$firstName;
    }

    But I am not getting any result, this code causes the form to hang.

    Any help would be appreciated.
    Thanks
    Andy

    https://ww.wp.xz.cn/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • I too would love to know how to to create alternate email messages, based on dropdown (or radio) selection. In my case, I’m working on a “Donation on behalf of” form, with a radio for either “Gift” or “In memory of”. Depending on which is selected, I’d like to customize the email message.

    Which brings up a related question, is there a way to create form fields that are contingent upon dropdown (or radio) selection? Thx!

Viewing 1 replies (of 1 total)

The topic ‘Variable body message based on dropdown value in form’ is closed to new replies.