Advertisement
maximus87

Untitled

Jul 23rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. add_filter( 'gform_admin_pre_render_2', 'populate_services' );
  2. function populate_services( $form ) {
  3.  
  4. foreach ( $form['fields'] as &$field ) {
  5.  
  6. if ( $field->type != 'select' || strpos( $field->cssClass, 'FIELD_CSS_CLASS_HERE' ) === false ) {
  7. continue;
  8. }
  9.  
  10. $terms = get_the_terms( $post->ID , array( 'TAXONOMY_HERE') );
  11. foreach( $terms as $term ) {
  12. $choices[] = array( 'text' => $term->name, 'value' => $term->name );
  13. }
  14. $field->placeholder = 'Select a service';
  15. $field->choices = $choices;
  16.  
  17. }
  18.  
  19. return $form;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement