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 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 See also


Top ↑

Parameters Parameters

$errors

(Required) WP_Error object.

$validation_results

(Required) The return value of a validation function like bp_core_validate_email_address().


Top ↑

Source Source

File: bp-members/bp-members-functions.php

function bp_core_add_validation_error_messages( WP_Error $errors, $validation_results ) {
	if ( ! empty( $validation_results['invalid'] ) ) {
		$errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) );
	}

	if ( ! empty( $validation_results['domain_banned'] ) ) {
		$errors->add( 'user_email',  __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
	}

	if ( ! empty( $validation_results['domain_not_allowed'] ) ) {
		$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
	}

	if ( ! empty( $validation_results['in_use'] ) ) {
		$errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.