Security · Guide
How to Recover a Hijacked WordPress Admin Account
Short answer
To recover a hijacked WordPress admin account, first try the Lost your password link on wp-login.php. If email no longer works, reset the password in phpMyAdmin with MD5, or with WP-CLI if you have server access. Then remove admin accounts you did not create, replace the security keys in wp-config.php to end every session, and scan the site for malware.
Key takeaways
- If the reset email still reaches you, use the Lost your password link on wp-login.php before you touch the database.
- Resetting a password in phpMyAdmin needs MD5 in the Function dropdown, and WordPress replaces that hash with a stronger one at the next login.
- An Administrator can install plugins, change users, and change settings, so any admin account you do not recognize must be removed at once.
- Replacing the eight keys and salts in wp-config.php ends every login session, including the attacker's session.
- Change passwords a second time after the site is clean, because a password changed while the attacker still had access may already be known.
- A clean remote scan does not prove the site is clean, because Sucuri SiteCheck only sees what a visitor sees in the browser.
How do you know your WordPress admin account was hijacked?
A hijacked admin account shows clear signs, such as a password that no longer works, a changed admin email, or new admin users.
Check for these signs before you change anything. Look at the login page, the user list if you can still get in, and any email from WordPress about a password or email change.
- Your password fails even though you typed it right.
- The admin email in your profile is one you do not recognize.
- New Administrator accounts appear in Users, then All Users.
- Posts, pages, or settings change without your action.
- Visitors report redirects, spam pages, or browser warnings.
WordPress.org lists a new user you did not create and a site flagged for malware among its signs of a hack, as described in its hacked-site guidance. Write down each sign, the time you saw it, and what changed recently, such as a new plugin or a new user.
What should you do first after a hijack?
First, record what you see, keep a copy of the site as it is, and tell your host.
Do not delete files or users yet. A copy of the infected site helps you and your host find how the attacker got in, and it gives you a way back if a cleanup step breaks the site.
- Write down the signs, the time you saw them, and recent changes.
- Save any password-change or user-change emails from WordPress.
- Back up WordPress before you change anything and keep that copy off the server.
- Ask your host if it has a clean backup from before the hijack, and ask it to check server logs.
- Scan your own computer for malware, since stolen passwords often come from an infected device.
The WordPress hacked-site guidance puts documentation first, then contact with the host, then a snapshot of the site before cleaning starts. That order matters because cleaning destroys clues about the entry point.
How do you get back in if you are locked out?
Use the email reset first, then phpMyAdmin or WP-CLI if email fails.
The login page is at wp-login.php in your site root, and visiting /wp-admin/ while logged out sends you to the same page. That detail comes from the WordPress developer docs on logging in.
Try the email reset
- Open
yoursite.com/wp-login.php. - Click “Lost your password?” below the login form.
- Enter your username or the email on the account.
- Click “Get New Password”.
- Open the email, click the reset link, and set a new long password.
This works only if you still control that email address and the site can send mail. If the attacker changed the admin email, the reset link goes to the attacker, so stop and use the database or WP-CLI method below.
If the reset email never arrives
Check spam and junk first. Then ask your host whether the site can send mail at all, since a site with broken mail never delivers the link.
If mail is broken or the email address was changed, do not keep requesting resets. Move to phpMyAdmin or WP-CLI, where you change the password without email.
How do you reset the admin password with phpMyAdmin?
You change the password directly in the wp_users table, with MD5 selected in the Function dropdown.
Back up the database first. The WordPress developer docs on logging in warn that direct database edits are high risk and should only be done by experienced database administrators.
- Open phpMyAdmin from your hosting panel.
- Select your WordPress database. Check
DB_NAMEinwp-config.phpif you have more than one. - Open the
wp_userstable. Your prefix may differ fromwp_. - Click Edit on your admin user row.
- In the
user_passfield, select MD5 from the Function dropdown. - Type your new password in the Value field.
- Click Go to save.
Selecting MD5 is required here. WordPress stores hashed passwords, so plain text in user_pass without a hashing function will not create a usable password. After your next login, WordPress replaces the temporary MD5 hash with a stronger hash.
Log in at once with the new password. If it works, change the password again from Users, then Your Profile, so the new password is set through WordPress itself.
How do you reset the admin password with WP-CLI?
WP-CLI resets the password from the server command line, without email and without editing database tables by hand.
The WordPress developer docs on logging in call WP-CLI the recommended approach when standard recovery is not available, because it is the safest and most direct method.
- Connect to your server by SSH and go to the WordPress folder.
- List users with
wp user listand note your admin username or ID. - Run
wp user update USERNAME --prompt=user_passand type the new password when asked. - Log in with the new password.
The --prompt=user_pass flag keeps the password out of your shell history. Patchstack also documents the same command in its guide to changing a WordPress password, with wp user update as the WP-CLI route.
If you need a random password, the WP-CLI reset-password command offers wp user reset-password USERNAME --show-password. It creates a new password and emails the user that the password changed, without putting the new password in the email. Use --show-password with care, since it prints the password in plain text on screen.
How do you remove admin accounts you did not create?
Open Users, then All Users, filter by Administrator, and delete every account you do not recognize.
WordPress has six default roles: Super Admin, Administrator, Editor, Author, Contributor, and Subscriber. That list comes from the WordPress roles and capabilities docs.
An Administrator has access to all administration features on a single site, so a stranger with that role can install plugins, change users, and change settings. That is why an unknown admin is not a small problem.
| Role | Can install plugins | Can manage users | What to do after a hijack |
|---|---|---|---|
| Administrator | Yes | Yes | Remove it if you do not know the person |
| Editor | No | No | Keep only if you know the person |
| Author | No | No | Keep only if you know the person |
| Contributor | No | No | Keep only if you know the person |
| Subscriber | No | No | Keep only if you know the person |
Check the email address and registration date of each admin account. A new admin with a strange email and a recent date is a strong sign of a backdoor account.
Delete unknown admins from the user list. If you cannot log in yet, list admins with wp user list --role=administrator and remove them with WP-CLI, or ask your host to help.
How do you log out the attacker everywhere?
Replace the eight security keys and salts in wp-config.php to end every login session at once.
A new password alone does not end a session the attacker already holds. Changing the keys forces every user, including the attacker, to log in again.
- Open the WordPress secret key generator and copy the eight lines it returns.
- Open
wp-config.phpin your site root. - Replace the block from
AUTH_KEYthroughNONCE_SALTwith the fresh lines. - Save the file and log in again with your new password.
The generator returns eight values: four keys and four salts, one pair for each of the auth, secure auth, logged in, and nonce schemes. The WordPress hardening guide explains that changing these values invalidates all existing cookies.
Also use Users, then Your Profile, then “Log Out Everywhere Else” if you can reach that screen. That ends sessions on other devices for your own account.
How do you check the site for malware after regaining access?
Run a scan from inside WordPress, then run a remote scan, and treat a clean remote result as a first check only.
Start with a plugin scan. Wordfence scans core files, themes, and plugins against the WordPress.org repository versions and checks for known malware, bad URLs, backdoors, and SEO spam, as described on the Wordfence plugin page.
- Set up the Wordfence firewall and run a full scan from Wordfence, then Scan.
- Read each result. Repair changed core, theme, or plugin files from the scan screen.
- Delete files that should not exist, such as PHP files in the uploads folder.
- Update WordPress, every plugin, and every theme from Dashboard, then Updates.
Then run a remote check. Sucuri SiteCheck at sitecheck.sucuri.net scans your public pages for known malware, blocklist status, website errors, and out-of-date software. Sucuri states that the scanner only sees what is visible at the browser level, so it will not detect server-side malware.
If you have a backup from before the hijack, restore a backup with UpdraftPlus only after you know the backup is clean. Restoring an infected backup puts the attacker back in.
How do you clear a Google warning after a hack?
Fix every issue Google lists, then click Request Review in the Security issues report in Google Search Console.
Google shows its findings in that report when it finds hacked content, malware, or social engineering on a site. That definition comes from the Google Search Console help on security issues.
- Verify the site in Search Console if you have not done so.
- Open Security and Manual Actions, then Security issues.
- Expand each issue and fix it on every page, not just the sample URLs shown.
- Click Request Review and describe the exact issue, the steps you took, and the outcome.
- Wait for the email decision. Do not send a second request while one is pending.
Google says most reconsideration reviews take several days or weeks, as of November 2026. A request sent before the issue is fixed can cause a longer wait for the next request, or get the site marked as a repeat offender.
How do you stop the same hijack from happening again?
Give each person the lowest role that lets them work, turn on two-factor login for admins, and keep everything updated.
The WordPress hardening guide recommends strong unique passwords, two-factor login for administrators, fewer administrator accounts, and regular updates. WordPress core does not include two-factor login, so add it with a trusted plugin.
- Use a long unique password from a password manager for every admin account.
- Turn on two-factor login for every Administrator and Editor.
- Remove admin accounts for people who no longer work on the site.
- Set directories to 755 and files to 644, as the hardening guide recommends.
- Add
define( 'DISALLOW_FILE_EDIT', true );towp-config.phpto block code editing from the dashboard. - Update WordPress, plugins, and themes as soon as updates appear.
The WordPress wp-config docs explain how to edit that file safely. Keep a copy of wp-config.php before you edit it, and test the site after each change.
What mistakes should you avoid?
Do not change only the admin password and call the job done, and do not clean files while the attacker still has a login.
A hijack often leaves a backdoor admin, a changed email, or stolen hosting and database passwords. If you skip those, the attacker returns with the same access.
- Changing the password before you remove unknown admins.
- Restoring a backup without checking whether it was made before the hijack.
- Installing plugins from unknown sources. Nulled plugins are not safe and can carry the next backdoor.
- Leaving the old security keys in place, so the attacker stays logged in.
- Asking Google for a review before every listed issue is fixed.
- Doing the whole cleanup alone when the site takes payments or holds customer data. In that case, ask your host or a cleanup service for help, and check the cost to hack-clean a WordPress site before you choose.
Work in order: regain access, remove unknown admins, end all sessions, clean and update, change every password again, then ask Google for a review if needed.
Frequently asked questions
Can I recover the admin account if the attacker changed the admin email?
Yes. The email reset will not help, because the link goes to the new address. Use phpMyAdmin to reset the password in the wp_users table with MD5, or use WP-CLI with wp user update and the prompt flag. After you log in, change the admin email back to an address you control, then remove any unknown admin accounts.
Should I delete the hijacked admin account and make a new one?
In most cases, no. Reset the password on the existing account, remove unknown admins, and replace the security keys so the attacker is logged out. A new admin account is useful only if the old account is badly damaged or you cannot tell which accounts are real. If you make a new admin, give it a different username and a long unique password.
Why do I have to change passwords twice after a hack?
A password changed while the attacker still had access may already be known to them, or the site may still hold a backdoor. WordPress guidance says to change passwords again once the site is clean. Change the WordPress admin, hosting, file access, database, and email passwords the second time, and replace the security keys as well.
How long does Google take to remove a warning after a hack?
Google says most reconsideration reviews take several days or weeks. The time depends on the issue type and how complete the fix is. Fix every listed issue on every page before you click Request Review, and do not send a second request while one is pending, since that can delay the next review.
Can I just restore a backup and skip the cleanup?
Only if the backup was made before the hijack and you have checked it is clean. A backup made after the attack may hold the same backdoor, changed users, or injected code. Restore the clean backup, then close the entry point, update everything, remove unknown admins, and change every password again.
Sources
- Logging In WordPress Developer Resources
- Roles and Capabilities WordPress.org
- Hardening WordPress WordPress Developer Resources
- wp user reset-password WordPress Developer Resources
- Security issues report Google Search Console Help
- Sucuri SiteCheck Sucuri
- Wordfence Security WordPress.org
- How to Quickly Change (Or Reset) WordPress Password Patchstack
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
