WordPress Security ServicesMalware Removal
Locked Out After a Hack

Hacked and Locked Out: Can't Log In, Unknown Admin Users, Can't Install Plugins

Your password suddenly doesn't work. Or you get in, but there are administrators you've never seen, and they come back after you delete them. Or WordPress won't let you install or update plugins anymore. These are classic signs of a hacked site where the attacker is protecting their access. Here's how to take your site back.

Sergey By Sergey, WordPress security specialist Updated 3 min read
In this guide
  1. Why you’re locked out
  2. Step 1: Get back in
  3. Step 2: Find every account the attacker created
  4. Step 3: Fix “can’t install or update plugins”
  5. Step 4: Lock it down

Why you’re locked out

When attackers take over a site, many make sure they keep control. The usual tricks:

  • Changing or resetting your password, or changing your account’s email.
  • Downgrading your account from administrator to subscriber.
  • Creating their own admin accounts, often with names like “wpadmin”, “support” or fake WordPress-looking emails, sometimes hidden from the Users screen.
  • Redirecting the login page to another site.
  • Disabling plugin installs and updates, so you can’t add a security plugin or patch the hole.

Step 1: Get back in

Try the normal reset first

Use Lost your password? on the login page. If the email never arrives, or your account’s email was changed, move on.

Reset the password with WP-CLI

If you have SSH access, list the administrators and reset your own password. The --skip-plugins --skip-themes flags stop malicious code from interfering:

wp user list --role=administrator --fields=ID,user_login,user_email --skip-plugins --skip-themes
wp user update YOUR_ID --prompt=user_pass --skip-plugins --skip-themes

--prompt asks for the password interactively, so it doesn’t end up in your shell history.

Reset it in phpMyAdmin

No SSH? Open phpMyAdmin from your hosting panel, find your user in the wp_users table, edit user_pass, choose the MD5 function, and enter a new password. WordPress accepts it and upgrades it to a stronger hash when you log in.

Create a new admin if yours was deleted

wp user create newadmin you@yourdomain.com --role=administrator --prompt=user_pass --skip-plugins --skip-themes

If the login page redirects elsewhere

Check siteurl and home (wp option get siteurl), and look in .htaccess for redirect rules you didn’t add. My redirect malware guide covers the usual hiding places.

Step 2: Find every account the attacker created

Compare the database with what the dashboard shows:

wp user list --fields=ID,user_login,user_email,user_registered,roles --skip-plugins --skip-themes

Look for accounts registered around the time of the hack, odd email domains, and anyone with administrator or editor rights you didn’t grant. Delete them and reassign their content to a real user. Then find the code that creates them: look in wp-content/mu-plugins, your theme’s functions.php, unknown plugins, and the WordPress cron list (wp cron event list). Otherwise they’ll be back.

Step 3: Fix “can’t install or update plugins”

If the Add New plugin button has disappeared, or updates are blocked, check wp-config.php for these lines:

define( 'DISALLOW_FILE_MODS', true );
define( 'DISALLOW_FILE_EDIT', true );

Attackers sometimes add DISALLOW_FILE_MODS so you can’t install security tools or patch the hole. If you didn’t add it yourself, remove it (DISALLOW_FILE_EDIT on its own is a good security setting, and worth keeping). Wrong file permissions or ownership can cause the same symptom, and your host can confirm.

Step 4: Lock it down

Once you’re back in: change all passwords, revoke application passwords, end all sessions (wp config shuffle-salts), and turn on two-factor authentication. Then clean the site, because an attacker who could change accounts almost certainly left a backdoor too. Follow how to secure WordPress after a hack.

From my cleanup work: a common case is a site with 7 or 8 extra administrators, all with emails that look like the owner’s or like WordPress.org addresses, added over a few days. The owner deleted them twice, and they came back twice. The cause was a few lines in a must-use plugin that recreated an admin whenever a secret URL was visited. Deleting accounts treats the symptom. Removing that code fixes it.

If you’re locked out and the site is down too, my emergency WordPress fix gets you back in and checks for malware as part of the job.

Sergey, WordPress Security Specialist
About the author
Sergey, WordPress Security Specialist

10 years in WordPress security and incident investigation, and more than 200 websites cleaned of malware. Top Rated on Upwork with a 100% Job Success score. More about me

Frequently Asked Questions

Why can't I see the hacker's admin account in the Users list?

Some malware hides its accounts from the WordPress dashboard by filtering the user list. The account still exists in the database. Check the wp_users table directly, or run wp user list with WP-CLI and the --skip-plugins --skip-themes flags so the malware can't interfere.

Why do deleted admin users keep coming back?

A backdoor or a scheduled task recreates them. Common places are a must-use plugin, code in the theme's functions.php, a fake plugin, or a WordPress cron event. Delete the account and find the code that creates it, or it will be back by tomorrow.

Is it safe to reset my password through the database?

Yes, if you do it carefully. WordPress accepts an MD5-hashed password set directly in the wp_users table and upgrades it to its stronger hash on your next login. Use a new, strong password and change it again from the dashboard once you're in.

Should I just reinstall WordPress?

Reinstalling core files doesn't remove the attacker's accounts, which live in the database, or backdoors in themes, plugins and uploads. Regain access first, then clean the site properly.

Need a hand?

Let me clean your WordPress site for you

Send me your site URL and what you're seeing. I'll reply with what I think is going on and the next step.

$95 per infected site · 1-month guarantee · direct contact with the specialist

Get My Site Cleaned →