wppaste
WordPress

apply_filters( 'authenticate', null|WP_User|WP_Error $user, string $username, string $password )

Since
2.8.0, 4.5.0
Filters whether a set of user login credentials are valid.

Description

A WP_User object is returned if the credentials authenticate a user.
WP_Error or null otherwise.

Compatibility

WordPress
since 4.5.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3).

Parameters

$usernull|WP_User|WP_Error
WP_User if the user is authenticated.
WP_Error or null otherwise.
$usernamestring
Username or email address.
$passwordstring
User password.

Where this hook fires · 1

  • wp-includes/pluggable.php:623wp_authenticate()

Source code

		 *		 * @param null|WP_User|WP_Error $user     WP_User if the user is authenticated.		 *                                        WP_Error or null otherwise.		 * @param string                $username Username or email address.		 * @param string                $password User password.		 */		$user = apply_filters( 'authenticate', null, $username, $password ); 		if ( null === $user || false === $user ) {			/*			 * TODO: What should the error message be? (Or would these even happen?)			 * Only needed if all authentication handlers fail to return anything.			 */

Changelog

Introduced in 2.8.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

Signature, return type and hooks compared across 5 parsed releases.

4.5.0
$username now accepts an email address.from the docblock
2.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.11 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.