bp_core_add_validation_error_messages

Add the appropriate errors to a WP_Error object, given results of a validation test.

Description

bp_core_add_validation_error_messages( (WP_Error) WP_Error $errors, (array) $validation_results ); 

Functions like bp_core_validate_email_address() return a structured array of error codes. bp_core_add_validation_error_messages() takes this array and parses, adding the appropriate error messages to the WP_Error object.

Parameters (2)

0. $errors (WP_Error) => WP_Error $errors
WP_Error object.
1. $validation_results (array)
The return value of a validation function like bp_core_validate_email_address().

Usage

  1. if ( !function_exists( 'bp_core_add_validation_error_messages' ) ) { 
  2. require_once '/bp-members/bp-members-functions.php'; 
  3.  
  4. // WP_Error object. 
  5. $errors = WP_Error $errors; 
  6.  
  7. // The return value of a validation function 
  8. // like bp_core_validate_email_address(). 
  9. $validation_results = array(); 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_core_add_validation_error_messages($errors, $validation_results); 
  13.  

Defined (1)

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

/bp-members/bp-members-functions.php  
  1. function bp_core_add_validation_error_messages( WP_Error $errors, $validation_results ) { 
  2. if ( ! empty( $validation_results['invalid'] ) ) { 
  3. $errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) ); 
  4.  
  5. if ( ! empty( $validation_results['domain_banned'] ) ) { 
  6. $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 
  7.  
  8. if ( ! empty( $validation_results['domain_not_allowed'] ) ) { 
  9. $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 
  10.  
  11. if ( ! empty( $validation_results['in_use'] ) ) { 
  12. $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );