um_admin_field_update_error_handling

The Ultimate Member um admin field update error handling function.

Description

um_admin_field_update_error_handling( $errors, $array ); 

Parameters (2)

0. $errors
The errors.
1. $array
The array.

Usage

  1. if ( !function_exists( 'um_admin_field_update_error_handling' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ultimate-member/admin/core/um-admin-filters-fields.php'; 
  3.  
  4. // The errors. 
  5. $errors = null; 
  6.  
  7. // The array. 
  8. $array = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = um_admin_field_update_error_handling($errors, $array); 
  12.  

Defined (1)

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

/admin/core/um-admin-filters-fields.php  
  1. function um_admin_field_update_error_handling( $errors, $array ) { 
  2. global $ultimatemember; 
  3. extract( $array ); 
  4.  
  5. $field_attr = $ultimatemember->builtin->get_core_field_attrs( $field_type ); 
  6.  
  7. if ( isset( $field_attr['validate'] ) ) { 
  8.  
  9. $validate = $field_attr['validate']; 
  10. foreach ( $validate as $post_input => $arr ) { 
  11.  
  12. $mode = $arr['mode']; 
  13.  
  14. switch ( $mode ) { 
  15.  
  16. case 'numeric': 
  17. if ( !empty( $array['post'][$post_input] ) && !is_numeric( $array['post'][$post_input] ) ) { 
  18. $errors[$post_input] = $validate[$post_input][error]; 
  19. break; 
  20.  
  21. case 'unique': 
  22. if ( !isset( $array['post']['edit_mode'] ) ) { 
  23. if ( $ultimatemember->builtin->unique_field_err( $array['post'][$post_input] ) ) { 
  24. $errors[$post_input] = $ultimatemember->builtin->unique_field_err( $array['post'][$post_input] ); 
  25. break; 
  26.  
  27. case 'required': 
  28. if ( $array['post'][$post_input] == '' ) 
  29. $errors[$post_input] = $validate[$post_input][error]; 
  30. break; 
  31.  
  32. case 'range-start': 
  33. if ( $ultimatemember->builtin->date_range_start_err( $array['post'][$post_input] ) && $array['post']['_range'] == 'date_range' ) 
  34. $errors[$post_input] = $ultimatemember->builtin->date_range_start_err( $array['post'][$post_input] ); 
  35. break; 
  36.  
  37. case 'range-end': 
  38. if ( $ultimatemember->builtin->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' ) 
  39. $errors[$post_input] = $ultimatemember->builtin->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ); 
  40. break; 
  41.  
  42.  
  43.  
  44.  
  45. return $errors; 
  46.