Definition:
function wp_authenticate($username, $password) {}
Checks a user’s login information and logs them in if it checks out.
Parameters
- string $username: User’s username
- string $password: User’s password
Return values
returns:WP_User object if login successful, otherwise WP_Error object.
Defined filters
- authenticate
apply_filters('authenticate', null, $username, $password)
Defined actions
- wp_login_failed
do_action('wp_login_failed', $username);
Source code
function wp_authenticate($username, $password) {
$username = sanitize_user($username);
$password = trim($password);
$user = apply_filters('authenticate', null, $username, $password);
if ( $user == null ) {
// TODO what should the error message be? (Or would these even happen?)
// Only needed if all authentication handlers fail to return anything.
$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
}
$ignore_codes = array('empty_username', 'empty_password');
if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
do_action('wp_login_failed', $username);
}
return $user;
}
3427

February 12, 2011 


No comments yet... Be the first to leave a reply!