ninja_forms_filter_term_ids_for_name

The Ninja Forms ninja forms filter term ids for name function.

Description

ninja_forms_filter_term_ids_for_name( $val, $field_id ); 

Parameters (2)

0. $val
The val.
1. $field_id
The field id.

Usage

  1. if ( !function_exists( 'ninja_forms_filter_term_ids_for_name' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/display/processing/term-name-filter.php'; 
  3.  
  4. // The val. 
  5. $val = null; 
  6.  
  7. // The field id. 
  8. $field_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_filter_term_ids_for_name($val, $field_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/display/processing/term-name-filter.php  
  1. function ninja_forms_filter_term_ids_for_name( $val, $field_id ) { 
  2. global $ninja_forms_loading, $ninja_forms_processing; 
  3.  
  4.  
  5. $add_field = apply_filters( 'ninja_forms_use_post_fields', false ); 
  6. if ( !$add_field ) 
  7. return $val; 
  8.  
  9. if ( isset ( $ninja_forms_loading ) ) { 
  10. $field_row = $ninja_forms_loading->get_field_settings( $field_id ); 
  11. } else { 
  12. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  13.  
  14. if ( $field_row['type'] == '_list' ) { 
  15. if ( isset( $field_row['data']['populate_term'] ) and !empty ( $field_row['data']['populate_term'] ) ) { 
  16. $tax = $field_row['data']['populate_term']; 
  17. if ( !is_array( $val ) ) { 
  18. if ( strpos( $val, ", " ) !== false ) { 
  19. $val = explode( ", ", $val ); 
  20. }  
  21.  
  22. if ( is_array( $val ) ) { 
  23. $tmp = ''; 
  24. $x = 0; 
  25. foreach ( $val as $v ) { 
  26. $term_obj = get_term( $v, $tax ); 
  27. if ( $term_obj AND !is_wp_error( $term_obj ) ) { 
  28. if ( $x == 0 ) { 
  29. $tmp .= $term_obj->name; 
  30. } else { 
  31. $tmp .= ', '.$term_obj->name; 
  32. $x++;  
  33. $val = $tmp; 
  34. } else { 
  35. $term_obj = get_term( $val, $tax ); 
  36. if ( $term_obj AND !is_wp_error( $term_obj ) ) { 
  37. $val = $term_obj->name;  
  38. }  
  39.  
  40. return $val;