Filter hook 'registration_errors'

in WP Core File wp-includes/user.php at line 3532

View Source

registration_errors

Filter Hook
Description
Filters the errors encountered when a new user is being registered. 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 be returned, but may or may not contain errors. If any errors are present in $errors, this will abort the user's registration.

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Filter
Line Number 3532

Hook Parameters

Type Name Description
WP_Error $errors A WP_Error object containing any errors encountered during registration.
string $sanitized_user_login User's username after it has been sanitized.
string $user_email User's email.

Usage Examples

Basic Usage
<?php
// Hook into registration_errors
add_filter('registration_errors', 'my_custom_filter', 10, 3);

function my_custom_filter($errors, $sanitized_user_login, $user_email) {
    // Your custom filtering logic here
    return $errors;
}

Source Code Context

wp-includes/user.php:3532 - How this hook is used in WordPress core
<?php
3527  	 * @param WP_Error $errors               A WP_Error object containing any errors encountered
3528  	 *                                       during registration.
3529  	 * @param string   $sanitized_user_login User's username after it has been sanitized.
3530  	 * @param string   $user_email           User's email.
3531  	 */
3532  	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
3533  
3534  	if ( $errors->has_errors() ) {
3535  		return $errors;
3536  	}
3537  

PHP Documentation

<?php
/**
	 * Filters the errors encountered when a new user is being registered.
	 *
	 * 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 be returned,
	 * but may or may not contain errors.
	 *
	 * If any errors are present in $errors, this will abort the user's registration.
	 *
	 * @since 2.1.0
	 *
	 * @param WP_Error $errors               A WP_Error object containing any errors encountered
	 *                                       during registration.
	 * @param string   $sanitized_user_login User's username after it has been sanitized.
	 * @param string   $user_email           User's email.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.