Per the comments I'm going to answer a paraphrased question - "How to make a login form which shows only the password field in most cases".
The answer is to store the user name in a very long term cookie (a year?) every time the user logins.
function wpse82578_set_user_cookie($logged_in_cookie, $expire, $expiration, $user_id, $state) {
if ($state == 'logged_in') { // user has logged in - store his name in a 'username' cookie
$user = get_user_by( 'id', $user_id );
setcookie('username', $user->user_login, time() + 365*24*60*60, COOKIEPATH, COOKIE_DOMAIN);
}
}
add_action('set_logged_in_cookie', 10,5);
Now in you PHP code you can check if the cookie is set and show or hide the user name field in your form.
function wpse82578_echo_login_form() {
...
if (isset($_COOKIE['username'])) { // already know the user name, no point in asking for it again so just put it as hidden field
<input type="hidden" name="log" value="<?php esc_attr($_COOKIE['username'])?> />
else { // show the field+label, ripped from wp_login_form
<p class="login-username">
<label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" tabindex="10" />
</p>
}
}
No warranties for this code, but I think it is the best approximation to what you want without sacrificing security and messing with the WordPress user system.
wp_hash_password
it generates a random string every time it runswp_check_password
and I think it might work, I can loop through the users table and check every hash against the string the user inputs and if something matches then return that user's ID. I'll give it a go.