Advertisement
HarunRRayhan

Pull Post to Gravity Forms List Field Column

Jun 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. // Dropdown for List Field
  2. add_filter( 'gform_column_input_3_43_1', 'hrx_list_colum_select', 10, 5 );
  3. function hrx_list_colum_select( $input_info, $field, $column, $value, $form_id ) {
  4.     global $post;
  5.     $exclude_events = get_post_meta($post->ID, 'same_night_events' );
  6.  
  7.     $choices = array();
  8.     $choices[]  = array( 'text' => 'Click to select', 'value' => '');
  9.  
  10.     $additional_events_query = new WP_Query(array(
  11.         'post_type'     => 'tribe_events',
  12.         'posts_per_page' => -1,
  13.         'tax_query' => array(
  14.             array(
  15.                 'taxonomy' => 'tribe_events_cat',
  16.                 'field'    => 'slug',
  17.                 'terms'    => array('series-classes', 'technique-clinics', 'workshops'),
  18.             ),
  19.         ),
  20.         'post__not_in' => $exclude_events,
  21.     ));
  22.  
  23.     if($additional_events_query->have_posts()){
  24.         while ($additional_events_query->have_posts()) {
  25.             $additional_events_query->the_post();
  26.             $choices[] = array( 'text' => get_the_title(), 'value' => get_the_title() );
  27.         }
  28.     }
  29.     return array( 'type' => 'select', 'choices' => $choices);
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement