Contact form 7 default option print as selected value in mail

[select my_select class:input class:styled "Select Options"   
"Option 1" "Option 2" "Option 3" "Option 4"]

Question:

How to prevent printing 'Select Options' if user not selected any options in receiving email?
If user select first option ('Select Options'),it should not print as 'Select Options' in mail.

Related posts

Leave a Reply

5 comments

  1. Change your select tag to the following

    [select my_select class:input class:styled include_blank "Option 1" "Option 2" "Option 3" "Option 4"]
    

    The first option will have “—” as the text and a blank value, <option value="">---</option>

    If you want to replace the text “—” with “Select Options” add the following code to functions.php

    function my_wpcf7_form_elements($html) {
        $text = 'Select Option';
        $html = str_replace('---',  $text , $html);
        return $html;
    }
    add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
    
  2. [select* BurjBestCompany default:get “The Best Advertising & Marketing Company” “The Best Airlines Company” ]

    BurjBestCompany should match with the query string name

    For example:

    http://example.com/?BurjBestCompany=The+Best+Advertising+%26+Marketing+Company
    
  3. Here is the Simple Solution to add Place Holder to select Drop Down Menu

    [select* Test first_as_label "Placeholder" "Option 1" "Option 2"]
    
  4. This solutions worked exact how I wanted. so all the forms have consistency and the same default selected – you need to add the ‘include_blank’ on the field shortcode:

    /**
     * Customize the default option selected on CF7
     */
     function my_wpcf7_form_elements($html) {
        $text = '—';
        $html = str_replace('---',  $text , $html);
        return $html;
    }
    add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');
    

    As https://stackoverflow.com/users/80368/anand-shah commented