ninja_forms_field_filter_list_data

The Ninja Forms ninja forms field filter list data function.

Description

ninja_forms_field_filter_list_data( $form_id ); 

Parameters (1)

0. $form_id
The form id.

Usage

  1. if ( !function_exists( 'ninja_forms_field_filter_list_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/list.php'; 
  3.  
  4. // The form id. 
  5. $form_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_field_filter_list_data($form_id); 
  9.  

Defined (1)

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

/deprecated/includes/fields/list.php  
  1. function ninja_forms_field_filter_list_data( $form_id ) { 
  2. global $ninja_forms_loading, $ninja_forms_processing; 
  3.  
  4. if ( isset ( $ninja_forms_loading ) ) { 
  5. $all_fields = $ninja_forms_loading->get_all_fields(); 
  6. } else { 
  7. return false; 
  8.  
  9. // Make sure we have some fields before displaying them! 
  10. if ( ! $all_fields ) { 
  11. return; 
  12.  
  13. // Loop through all of our fields and see if we have any list fields. 
  14.  
  15. foreach( $all_fields as $field_id => $user_value ) { 
  16. $tmp_array = array(); 
  17. if ( isset ( $ninja_forms_loading ) ) { 
  18. $field = $ninja_forms_loading->get_field_settings( $field_id ); 
  19. } else { 
  20. // $field = $ninja_forms_processing->get_field_settings( $field_id ); 
  21.  
  22. $field_type = $field['type']; 
  23. $data = $field['data']; 
  24. // Check to see if we are working with a list. If so, filter the default_value 
  25. if( $field_type == '_list' && empty( $user_value ) ) { 
  26. if( isset( $data['list']['options'] ) AND is_array( $data['list']['options'] ) AND !empty( $data['list']['options'] ) ) { 
  27. foreach( $data['list']['options'] as $option ) { 
  28. if( isset( $option['selected'] ) AND $option['selected'] == 1 ) { 
  29. if( isset( $data['list_show_value'] ) AND $data['list_show_value'] == 1 ) { 
  30. $tmp_array[] = $option['value']; 
  31. }else{ 
  32. $tmp_array[] = $option['label']; 
  33. if ( empty( $tmp_array ) AND $data['list_type'] == 'dropdown' AND $data['label_pos'] != 'inside' ) { 
  34. if ( isset ( $data['list_show_value'] ) AND $data['list_show_value'] == 1 AND $data['label_pos'] != 'inside' ) { 
  35. $tmp_array[] = $data['list']['options'][0]['value']; 
  36. } else { 
  37. $tmp_array[] = $data['list']['options'][0]['label']; 
  38. if ( isset ( $ninja_forms_loading ) ) { 
  39. if ( $ninja_forms_loading->get_field_settings( $field_id ) ) { 
  40. $ninja_forms_loading->update_field_value( $field_id, $tmp_array ); 
  41. } else { 
  42. // if ( !$ninja_forms_processing->get_field_value( $field_id ) ) { 
  43. // $ninja_forms_processing->update_field_value( $field_id, $tmp_array ); 
  44. // }