Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('gform_pre_render_6', 'populate_coach');
- function populate_coach($form){
- foreach($form['fields'] as &$field){
- if($field['type'] != 'select' || strpos($field['cssClass'], 'populate-agenda-coach') === false)
- continue;
- // you can add additional parameters here to alter the posts that are retreieved
- // more info: http://codex.wordpress.org/Template_Tags/get_posts
- $posts = get_posts('category=221&numberposts=18');
- // update 'Select a Post' to whatever you'd like the instructive option to be
- $choices = array(array('text' => 'Choisir une date', 'value' => ' '));
- foreach($posts as $post){
- $choices[] = array('text' => get_post_meta($post_id, 'custom_field_name', false) , 'value' => get_post_meta($post_id, 'custom_field_name', false) );
- }
- $field['choices'] = $choices;
- }
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement