gleenk
5/7/2015 - 1:57 PM

ACF custom field select to Contact Form 7 for WordPress

ACF custom field select to Contact Form 7 for WordPress

function add_date_to_cf7() {

	$output = "<select name='date_corso' id='date_corso' onchange='document.getElementById(\"date_corso\").value=this.value;'><option></option>";

	if( have_rows('gruppo_date') ) {
        while( have_rows('gruppo_date') ) {
            the_row();
           
           $output .= '<option value="'.get_sub_field('intervallo_date_corso').'">' .get_sub_field('intervallo_date_corso'). '</option>';

        }
    }
	$output .= "</select>";

	return $output;
}

wpcf7_add_shortcode('date_corso', 'add_date_to_cf7', true);