Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_authenticate [ WordPress Function ]

wp_authenticate ( $username, $password )
Parameters:
  • (string) $username User's username
  • (string) $password User's password
Returns:
  • (WP_Error|WP_User) WP_User object if login successful, otherwise WP_Error object.
Defined at:



Checks a user's login information and logs them in if it checks out.

Source


<?php
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;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics