authenticate

Filter whether a set of user login credentials are valid.

Description

apply_filters( 'authenticate', (null) $null, (string) $username, (string) $password ); 

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

Parameters (3)

0. $null (null) => null
WP_User if the user is authenticated. WP_Error or null otherwise.
1. $username (string)
Username or email address.
2. $password (string)
The password.

Usage

To run the hook, copy the example below.
  1. $null = apply_filters( 'authenticate', $null, $username, $password ); 
  2.  
  3. if ( !empty( $null ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the authenticate callback 
  2. function filter_authenticate( $null, $username, $password ) { 
  3. // make filter magic happen here... 
  4. return $null
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'authenticate', 'filter_authenticate', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'authenticate', 'filter_authenticate', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/pluggable.php  
  1. $user = apply_filters( 'authenticate', null, $username, $password );