• Resolved IT Hertz

    (@it-hertz)


    I need to get the selected dropdown value (index would be helpful, too) to use in this function:

    add_action('wpcf7_before_send_mail', 'do_stuff_with_data');
    function do_stuff_with_data($formdata) {
       if ($formdata->id() == 1000) {
          $submission = WPCF7_Submission::get_instance();
          if ($submission) {
             $posted_data = $submission->get_posted_data();
          }
          $item1 = $posted_data['text_field'];
          $item2 = $posted_data['dropdown'];
       }
    }

    That gets text field value, but does not get dropdown selection value.

    I’d rather keep this PHP and avoid escaping JS/jQuery to do a selectedIndex on the DOM (I presume the “id” option in the CF7 tag would be what I’d use).

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I get dropdown selected value?’ is closed to new replies.