bp_core_add_validation_error_messages( WP_Error $errors, array $validation_results )
Add the appropriate errors to a WP_Error object, given results of a validation test.
Description
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.
See also
Parameters
- $errors
-
(Required) WP_Error object.
- $validation_results
-
(Required) The return value of a validation function like bp_core_validate_email_address().
Source
File: bp-members/bp-members-functions.php
1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 | function bp_core_add_validation_error_messages( WP_Error $errors , $validation_results ) { if ( ! empty ( $validation_results [ 'invalid' ] ) ) { $errors ->add( 'user_email' , __( 'Please enter a valid email address.' , 'buddyboss' ) ); } if ( ! empty ( $validation_results [ 'domain_banned' ] ) ) { $errors ->add( 'user_email' , __( 'Sorry, that email address is not allowed!' , 'buddyboss' ) ); } if ( ! empty ( $validation_results [ 'domain_not_allowed' ] ) ) { $errors ->add( 'user_email' , __( 'Sorry, that email address is not allowed!' , 'buddyboss' ) ); } if ( ! empty ( $validation_results [ 'in_use' ] ) ) { $errors ->add( 'user_email' , __( 'Sorry, that email address is already used!' , 'buddyboss' ) ); } } |
Changelog
Version | Description |
---|---|
BuddyPress 1.7.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.