Thank you. Here is the code for populating the dropdown.
// used for populating tour webinars
add_filter('gform_pre_render_16', 'populate_tour_webinars');
function populate_tour_webinars($form){
global $post;
// Get posts for "GiftWorks Overview Tours"
$args = array( 'post_type' => 'event',
'orderby' => 'menu_order',
'tax_query' => array(
array(
'taxonomy' => 'event-category',
'field' => 'slug',
'terms' => 'tours'
)
),
'numberposts' => 10);
$posts = get_posts( $args );
// Create drop down tour items array.
$items = array();
// Add initial blank value.
$items[] = array("text" => "Select Date/Time (Eastern Time)", "value" => "Select Date/Time (Eastern Time)");
// Add post items to the tour items array
foreach($posts as $post)
{
$gtwid = get_post_meta($post->ID, 'gtwid', true);
$startdate = get_post_meta($post->ID, '_eventorganiser_schedule_start_start', true);
$enddate = get_post_meta($post->ID, '_eventorganiser_schedule_start_finish', true);
$startdatetime = strtotime( $startdate );
$enddatetime = strtotime( $enddate );
$display = date("D, M j, Y g:i A", $startdatetime ) . ' - ' . date("g:i A", $enddatetime ) . ' EST ' .
date("(m/d/y)", $startdatetime );
$items[] = array("value" => $gtwid, "text" => $display);
}
foreach($form["fields"] as &$field)
if($field["inputName"] == "gtwid"){
$field["choices"] = $items;
}
return $form;
}
Posted 11 years ago on Wednesday December 12, 2012 |
Permalink