Advertisement
Guest User

Untitled

a guest
Nov 16th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. add_filter("gform_pre_render_6", "populate_event_metaCreators");
  2.    
  3. function populate_event_metaCreators($form){
  4.     $postOptions = NULL;
  5.    
  6.     foreach($form['fields'] as &$field) {
  7.         switch ($field['inputName']) {
  8.             case 'OrganizerSelect':
  9.                
  10.                 global $wpdb;
  11.                 $postOptions = $wpdb->get_results
  12.                 ("SELECT ID, post_title FROM $wpdb->posts where post_type = 'tribe_organizer' and post_status = 'publish' order by post_title ASC");
  13.  
  14.                 break;
  15.                
  16.             case 'VenueSelect':
  17.            
  18.                 global $wpdb;
  19.                 $postOptions = $wpdb->get_results
  20.                 ("SELECT ID, post_title FROM $wpdb->posts where post_type = 'tribe_venue' and post_status = 'publish' order by post_title ASC");
  21.  
  22.                 break;
  23.         }
  24.        
  25.         if($postOptions != NULL) {
  26.             $choices = '';
  27.             $choices[] = array('text' => '', 'value' => '', 'isSelected' => '', 'price' => '');
  28.             $choices[] = array('text' => 'Add New Entry', 'value' => 'Add New Entry', 'isSelected' => '', 'price' => '');
  29.            
  30.             foreach ($postOptions as $postOption) {
  31.                 $choices[] = array('text' => $postOption->post_title, 'value' =>  $postOption->ID, 'isSelected' => '', 'price' => '');
  32.             }
  33.             $field['choices'] = $choices;  
  34.            
  35.             $postOptions = NULL;
  36.         }
  37.        
  38.     }
  39.    
  40.     return $form;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement