• Hi there,

    I have created a form with a select option.

    This select option has an ID of menu-761

    The form will be used on different pages, but I would like the select to be pre-selected depending on what page they are sending the form from.

    [contact-form-7 id=”166″ menu-761=”Drivers Package” title=”calmer connection call”]

    I tried that but it doesn’t change the dropdown menu.

    Is there a way to do it?

    Many thanks

    Adam

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter chalkie1983uk

    (@chalkie1983uk)

    Okay So i did this:

    Functions.php has this:

    add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 );

    function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
    $my_attr = ‘choice’;

    if ( isset( $atts[$my_attr] ) ) {
    $out[$my_attr] = $atts[$my_attr];
    }

    return $out;
    }

    My form has this:

    [select menu-761 default:shortcode_attr “Private 1-2-1 Sessions” “Drivers Package” “Interview Package” “Exam Package” “Other” ]

    and my shortcode on the page has this:

    [contact-form-7 id=”166″ title=”calmer connection call” choice=”3″]

    Meaning the drop down should be selected as Interview Package. But it doesn’t work.

    I tried it with and without the “” in the shortcode but it didn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using shortcode to select a dropdown option’ is closed to new replies.