ninja_forms_req_fields_process

The Ninja Forms ninja forms req fields process function.

Description

ninja_forms_req_fields_process(); 

Usage

  1. if ( !function_exists( 'ninja_forms_req_fields_process' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/display/processing/req-fields-pre-process.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ninja_forms_req_fields_process(); 
  7.  

Defined (1)

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

/deprecated/includes/display/processing/req-fields-pre-process.php  
  1. function ninja_forms_req_fields_process() { 
  2. global $ninja_forms_processing, $ninja_forms_fields; 
  3.  
  4. $all_fields = $ninja_forms_processing->get_all_fields(); 
  5.  
  6. if( is_array( $all_fields ) AND !empty( $all_fields ) ) { 
  7. foreach($all_fields as $field_id => $user_value) { 
  8.  
  9. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  10.  
  11. if ( !$field_row ) { 
  12. $field_row = ninja_forms_get_field_by_id( $field_id ); 
  13.  
  14. $field_type = $field_row['type']; 
  15.  
  16. if ( isset ( $ninja_forms_fields[$field_type] ) ) { 
  17.  
  18. if( isset( $field_row['data'] ) ) { 
  19. $field_data = $field_row['data']; 
  20. }else{ 
  21. $field_data = ''; 
  22.  
  23. if( isset( $field_data['req'] ) ) { 
  24. $req = $field_data['req']; 
  25. }else{ 
  26. $req = ''; 
  27.  
  28. if( isset( $field_data['label_pos'] ) ) { 
  29. $label_pos = $field_data['label_pos']; 
  30. }else{ 
  31. $label_pos = ''; 
  32. // Get the required field symbol. 
  33. $settings = nf_get_settings(); 
  34. if ( isset ( $settings['req_field_symbol'] ) ) { 
  35. $req_symbol = $settings['req_field_symbol']; 
  36. } else { 
  37. $req_symbol = '*'; 
  38.  
  39. if ( isset ( $field_data['req'] ) and $field_data['req'] == 1 and $label_pos == 'inside' ) { 
  40. $field_data['label'] .= ' '.$req_symbol; 
  41.  
  42. if( isset( $field_data['label'] ) ) { 
  43. $label = $field_data['label']; 
  44. }else{ 
  45. $label = ''; 
  46.  
  47. $label = strip_tags( $label ); 
  48.  
  49. $reg_type = $ninja_forms_fields[$field_type]; 
  50. $req_validation = $reg_type['req_validation']; 
  51.  
  52. $plugin_settings = nf_get_settings(); 
  53. if ( isset ( $plugin_settings['req_field_error'] ) ) { 
  54. $req_field_error = __( $plugin_settings['req_field_error'], 'ninja-forms' ); 
  55. } else { 
  56. $req_field_error = __( 'This is a required field.', 'ninja-forms' ); 
  57.  
  58. if( isset( $plugin_settings['req_error_label'] ) ) { 
  59. $req_error_label = __( $plugin_settings['req_error_label'], 'ninja-forms' ); 
  60. }else{ 
  61. $req_error_label = __( 'Please check required fields.', 'ninja-forms' ); 
  62.  
  63. if( $req == 1 AND $user_value !== false ) { 
  64.  
  65. if($req_validation != '') { 
  66. $arguments['field_id'] = $field_id; 
  67. $arguments['user_value'] = $user_value; 
  68. $req = call_user_func_array($req_validation, $arguments); 
  69. if(!$req) { 
  70. $ninja_forms_processing->add_error('required-'.$field_id, $req_field_error, $field_id); 
  71. $ninja_forms_processing->add_error('required-general', $req_error_label, 'general'); 
  72. }else{ 
  73. if($label_pos == 'inside') { 
  74. if( $user_value == $label OR ( empty( $user_value ) && $user_value !== "0" ) ) { 
  75. $ninja_forms_processing->add_error('required-'.$field_id, $req_field_error, $field_id); 
  76. $ninja_forms_processing->add_error('required-general', $req_error_label, 'general'); 
  77. }else{ 
  78. if( $user_value === '' ) { 
  79. $ninja_forms_processing->add_error('required-'.$field_id, $req_field_error, $field_id); 
  80. $ninja_forms_processing->add_error('required-general', $req_error_label, 'general');