Advertisement
Guest User

Untitled

a guest
Dec 9th, 2013
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. add_filter('gform_pre_render_6', 'populate_coach');
  2. function populate_coach($form){
  3.     foreach($form['fields'] as &$field){
  4.         if($field['type'] != 'select' || strpos($field['cssClass'], 'populate-agenda-coach') === false)
  5.             continue;
  6.         // you can add additional parameters here to alter the posts that are retreieved
  7.         // more info: http://codex.wordpress.org/Template_Tags/get_posts
  8.         $posts = get_posts('category=221&numberposts=18');
  9.         // update 'Select a Post' to whatever you'd like the instructive option to be
  10.         $choices = array(array('text' => 'Choisir une date', 'value' => ' '));
  11.         foreach($posts as $post){
  12.             $choices[] = array('text' => get_post_meta($post_id, 'custom_field_name', false) , 'value' => get_post_meta($post_id, 'custom_field_name', false) );
  13.         }
  14.         $field['choices'] = $choices;
  15.     }    
  16.     return $form;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement