Filter hook 'authenticate'

in WP Core File wp-includes/pluggable.php at line 623

View Source

authenticate

Filter Hook
Description
Filters whether a set of user login credentials are valid. A WP_User object is returned if the credentials authenticate a user. WP_Error or null otherwise.

Hook Information

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

Hook Parameters

Type Name Description
null|WP_User|WP_Error $user WP_User if the user is authenticated. WP_Error or null otherwise.
string $username Username or email address.
string $password User password.

Usage Examples

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

function my_custom_filter($user, $username, $password) {
    // Your custom filtering logic here
    return $user;
}

Source Code Context

wp-includes/pluggable.php:623 - How this hook is used in WordPress core
<?php
 618  		 * @param null|WP_User|WP_Error $user     WP_User if the user is authenticated.
 619  		 *                                        WP_Error or null otherwise.
 620  		 * @param string                $username Username or email address.
 621  		 * @param string                $password User password.
 622  		 */
 623  		$user = apply_filters( 'authenticate', null, $username, $password );
 624  
 625  		if ( null === $user || false === $user ) {
 626  			/*
 627  			 * TODO: What should the error message be? (Or would these even happen?)
 628  			 * Only needed if all authentication handlers fail to return anything.

PHP Documentation

<?php
/**
		 * Filters whether a set of user login credentials are valid.
		 *
		 * A WP_User object is returned if the credentials authenticate a user.
		 * WP_Error or null otherwise.
		 *
		 * @since 2.8.0
		 * @since 4.5.0 `$username` now accepts an email address.
		 *
		 * @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.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/pluggable.php
Related Hooks

Related hooks will be displayed here in future updates.