関数 wp_authenticate_username_password()
2014/12/17
関数 wp_authenticate_username_password()
定義ファイル :/blog/wp-includes/user.php 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | function wp_authenticate_username_password($user, $username, $password) { if ( is_a( $user, 'WP_User' ) ) { return $user; } if ( empty($username) || empty($password) ) { if ( is_wp_error( $user ) ) return $user; $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">Lost your password</a>?' ), wp_lostpassword_url() ) ); $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">Lost your password</a>?' ), $username, wp_lostpassword_url() ) ); return $user; } |