How to bypass login in WordPress


This is a small PHP-script that you can save in a PHP-file and move to the root directory of your WordPress site. Navigate to it through your browser and it will automatically authenticate you as the user you choose. It’s a good tool to have laying around if you get locked out of your own site.

And please remember to remove it once you’re done, in case someone else finds out about it.



auto_login("admin");  // Change this to your username

function auto_login($username) {
    $user = get_userdatabylogin($username);
    $user_id = $user->ID;
    wp_set_current_user($user_id, $user_login);
    do_action('wp_login', $user_login);