• Resolved t00kie

    (@t00kie)


    I am fully aware of danger!

    I need to force wordpress to have users login only by username. It’s na intranet site, they will be login with RFID cards, so I don’t need any passwords. Is there any plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello t00kie,

    Please add the below line of code in your theme function.php which will allows you to login into WP without using the password.

    <?php
    
    function admin_login($user, $username, $password) {
        $user = get_user_by("login", $username);
    
        if($user != "FALSE")
        {
            wp_set_auth_cookie($user->ID);
        }
        else
        {
            return null;
        }
        return $user;
    }
    
    function hide_password_field()
    {
        ?>
            <style type="text/css">
                body.login div#login form#loginform p:nth-child(2) {
                    display: none;
                }
            </style>
        <?php
    }
    
    add_filter("authenticate", "admin_login", 10, 3);
    add_action("login_head", "hide_password_field");
    ?>

    Thanks

    Thread Starter t00kie

    (@t00kie)

    Works like charm! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Log in only with username’ is closed to new replies.