wp_authenticate_username_password [ WordPress Functions ]
wp_authenticate_username_password ( $user, $username, $password )
| Defined at: |
|
| Codex |
Similar Functions: wp_generate_password, wp_authenticate, generate_random_password, wp_authenticate_cookie, wp_hash_password
No description yet.
Source
function wp_authenticate_username_password($user, $username, $password) {
if ( is_a($user, 'WP_User') ) { return $user; }
if ( empty($username) || empty($password) ) {
$error = new WP_Error();
if ( empty($username) )
$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
if ( empty($password) )
$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
return $error;
}
$user = get_user_by('login', $username);
if ( !$user )
return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?' ), wp_lostpassword_url() ) );
if ( is_multisite() ) {
// Is user marked as spam?
if ( 1 == $user->spam )
return new WP_Error( 'spammer_account', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.' ) );
// Is a user's blog marked as spam?
if ( !is_super_admin( $user->ID ) && isset( $user->primary_blog ) ) {
$details = get_blog_details( $user->primary_blog );
if ( is_object( $details ) && $details->spam == 1 )
return new WP_Error( 'blog_suspended', __( 'Site Suspended.' ) );
}
}
$user = apply_filters('wp_authenticate_user', $user, $password);
if ( is_wp_error($user) )
return $user;
if ( !wp_check_password($password, $user->user_pass, $user->ID) )
return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' ),
$username, wp_lostpassword_url() ) );
return $user;
}Examples [ wp-snippets.com ]
Top Google Search Results
- wp_authenticate_username_password (WordPress Function ...
WordPress lookup for wp_authenticate_username_password, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme ...
wpseek.com - How to check username/password without signing in the user
Aug 9, 2012 ... The best choice for what I'm doing is wp_authenticate_username_password($ user, $username, $password) because it DOESN'T set the login ...
wordpress.stackexchange.com - WordPress › Support » remove_filter('authenticate ...
I am writing an authentication plugin that attaches a filter to 'authenticate'. I want to prevent lower priority filters from authorizing login if my plugin fails.
wordpress.org - wp_authenticate_username_password() WordPress function ...
Authenticate the user using the username and password.
queryposts.com
