I would like to user a single field form to pass a username to the wp-login (without password)

something like mysite.com/wordpress/wp-login?username=dave - although the form could, of course be POST rather than GET

I can find lots of advice on how not to pass the password, sensibly enough, but passing the username isn't particularly dangerous as these wouldn't be admin users.

1 Answer 1


This code should accomplish what you're after:

function login_username() {
    if (isset($_REQUEST['username'])) {
        echo "    <style type='text/css'>               
        body.login #user_login, body.login label[for=user_login] {
            display: none;
        global $user_login;
        return $user_login = sanitize_user($_REQUEST['username'], true);
add_action('login_head', 'login_username');

Since you're on the login page, get_query_var() isn't an option, but you can retrieve and pass the username with a sanitized $_REQUEST['username'].

Adding the CSS will hide the username field (I'm assuming that's what you were asking for) when the username has been passed via the url.

  • Looks like it should do it. Thank you. I don't need to hide the username but the swapping the REQUEST variable into the $user_login variable is exactly what I need. Amazingly enough this conversation seemed to trigger a related post with the answer ( I did search, honest!) so this might be a duplicate of wordpress.stackexchange.com/questions/39994/…
    – Chris Pink
    Aug 22, 2019 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.