Created
August 21, 2014 16:08
-
-
Save jonschr/85b45c4ecd23703a19f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('gform_pre_render_2', 'rb_populate_posts'); | |
function rb_populate_posts( $form ) { | |
foreach( $form['fields'] as &$field ){ | |
if( strpos( $field['cssClass'], 'eventsselection' ) === false ) | |
continue; | |
$posts = get_posts( 'post_type=events&numberposts=-1' ); | |
$choices = array( | |
array( | |
'text' => "- Select the event you're registering for -", | |
'value' => 0 | |
) | |
); | |
foreach( $posts as $post ) { | |
$choices[] = array( | |
'text' => $post->post_title, | |
'value' => $post->post_title, | |
); | |
} | |
$field['choices'] = $choices; | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment