Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'gform_admin_pre_render_2', 'populate_services' );
- function populate_services( $form ) {
- foreach ( $form['fields'] as &$field ) {
- if ( $field->type != 'select' || strpos( $field->cssClass, 'FIELD_CSS_CLASS_HERE' ) === false ) {
- continue;
- }
- $terms = get_the_terms( $post->ID , array( 'TAXONOMY_HERE') );
- foreach( $terms as $term ) {
- $choices[] = array( 'text' => $term->name, 'value' => $term->name );
- }
- $field->placeholder = 'Select a service';
- $field->choices = $choices;
- }
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement