WP Plugin Easy fancybox / Contact Form 7 prefill dropdown

23 Views Asked by At

I'm trying to prefill a dropdown element from contact form 7 with values from the cf7-shortcode call via the easy fancybox plugin. I already do this with textfield which is working fine. But i cannot get it working with dropdown fields.

For the textfield elements i'm using the following as the easybox call:

<a href="#contact_form_pop" class="btn fancybox-inline" aria-controls="fancybox-wrap" aria-haspopup="dialog" draggable="false">Jetzt anmelden</a>
<div class="fancybox-hidden" style="display: none;">
<div id="contact_form_pop" class="hentry contact-form-popup">[contact-form-7 id="ec94574" title="ohne titel" anmeldungfuer="Kursname"]</div>
</div>

In my functions.php this:

add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
 
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
    $my_attr = 'anmeldungfuer';
 
    if ( isset( $atts[$my_attr] ) ) {
        $out[$my_attr] = $atts[$my_attr];
    }
    
    return $out;
}

In my contactform i can access it via:

[text* anmeldungfuer default:shortcode_attr]

This is working well for textfields. But i want the same for a select element but cannot get it to work. Is there any possibility to this? Thanks for your help!

0

There are 0 best solutions below