apply_filters( 'authenticate', null|WP_User|WP_Error $user , string $username , string $password )
Filters whether a set of user login credentials are valid.
Contents
Description
A WP_User object is returned if the credentials authenticate a user.
WP_Error or null otherwise.
Parameters
More Information
The authenticate filter hook is used to perform additional validation/authentication any time a user logs in to WordPress.
The wp_authenticate_user filter can also be used if you want to perform any additional validation after WordPress’s basic validation, but before a user is logged in.
The default authenticate filters in /wp-includes/default-filters.php
add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 );
add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 );
Source
File: wp-includes/pluggable.php
.
View all references
$user = apply_filters( 'authenticate', null, $username, $password );
Changelog
Version | Description |
---|---|
4.5.0 | $username now accepts an email address. |
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
==Examples==
The basic usage is as follows…
This hook passes three parameters, $user, $username and $password. In order to generate an error on login, you will need to return a WP_Error object.
Goes nicely with:
… or simply return null.
WordPress will assign a standard WP_Error object: