registration_errors

Filters the errors encountered when a new user is being registered.

Description

apply_filters( 'registration_errors', (WP_Error) $errors, (string) $sanitized_user_login, (string) $user_email ); 

The filtered WP_Error object may, for example, contain errors for an invalid or existing username or email address. A WP_Error object should always returned, but may or may not contain errors.

If any errors are present in $errors, this will abort the user's registration.

Parameters (3)

0. $errors (WP_Error)
A WP_Error object containing any errors encountered during registration.
1. $sanitized_user_login (string)
User's username after it has been sanitized.
2. $user_email (string)
The user email.

Usage

To run the hook, copy the example below.
  1. $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 
  2.  
  3. if ( !empty( $errors ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the registration_errors callback 
  2. function filter_registration_errors( $errors, $sanitized_user_login, $user_email ) { 
  3. // make filter magic happen here... 
  4. return $errors
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'registration_errors', 'filter_registration_errors', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'registration_errors', 'filter_registration_errors', 10, 3 ); 

Defined (1)

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

/wp-includes/user.php  
  1. $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );