Код: Выделить всё
//Populate Webinars form field for Webinar dates
add_filter( 'gform_pre_render_2', 'populate_webinar_dates' );
function populate_webinar_dates( $form ) {
foreach( $form[ 'fields' ] as &$field ) {
if( $field[ 'type' ] != 'select' || strpos( $field[ 'cssClass' ], 'populate-dates' ) === false )
continue;
$posts = new WP_Query( 'numberposts=-1&post_status=publish&post_type=vtl_webinar' );
$choices = 'Select a date';
while ( $posts->have_posts() ) : $posts->the_post();
while ( has_sub_field( 'dates_available' ) ) :
$post_dates = array( 'date' => get_sub_field( 'date' ) );
$post_title = array( 'name' => str_replace( " ", "-", get_the_title() ) );
//$choices[] = array( 'text' => $post_dates['date'], 'value' => $post_dates['date'] );
$choices = '' . $post_dates['date'] . '';
endwhile;
endwhile;
$field[ 'choices' ] = $choices;
}
return $form;
}
Код: Выделить всё
$choices = '' . $post_dates['date'] . '';
Подробнее здесь: https://stackoverflow.com/questions/278 ... vity-forms