In this guide
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.