WordPress.org

Codex

Plugin API/Filter Reference/authenticate

This page is marked as incomplete. You can help Codex by expanding it.

Contents

Description

The authenticate filter hook is used to perform additional validation/authentication any time a user logs in to WordPress.

Note: wp_authenticate_user can also be used if you want to perform any additional validation after WordPress's basic validation, but before a user is logged in.

Parameters

$username
(string) (required) The user's username.
Default: None
$password
(string) (optional) The user's password (encrypted).
Default: None

Returns

This hook should return either a WP_User() object or, if generating an error, a WP_Error() object.

Examples

The basic usage is as follows...

add_filter('authenticate', 'myplugin_auth_signon', 30, 3);
function myplugin_auth_signon ($username, $password) {
     return $user;
}

This hook passes two parameters, $user and $password (encrypted). In order to generate an error on login, you will need to return a new WP_Error() object.

Source File

The authenticate hook is located in /wp-includes/pluggable.php within wp_authenticate()

Related

Filter Hooks

Return to Plugin API/Filter Reference