registration_errors WordPress Filter Hook

The registration_errors hook is an action hook that is called when a user submits the registration form. It allows you to add errors to the registration form. This hook is useful for adding custom errors to the registration form. For example, if you want to require that users enter a unique username, you can use this hook to add an error if the username is already taken.

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

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


Description

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.


Top ↑

Parameters

$errors

(WP_Error)A WP_Error object containing any errors encountered during registration.

$sanitized_user_login

(string)User's username after it has been sanitized.

$user_email

(string)User's email.


Top ↑

More Information

This filter can be used to create custom validation rules on user registration. This fires when the form is submitted but before user information is saved to the database.

When used with other hooks, this filter can be used to create custom registration processes.

The form will not create a new user if any errors are returned. Notice: The function must return the variable $errors in any case (even when there is no error in your logic), otherwise the function may cause this problem: Fatal error: Call to a member function get_error_code() on a non-object.


Top ↑

Source

File: wp-includes/user.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More