For WordPress sites past the first hour

WordPress site hacked? How to fix it, step by step

Unknown admin users, redirects you never set up, files you don't recognise. Once you have documented the hack and taken the site offline, this is the WordPress-specific work that comes next: which screens to open, which files to replace, and how to find the plugin that let the attacker in.

The short answer: how to fix a hacked WordPress site

  • If you haven't done the first-hour basics yet (document, take the site offline, change passwords, call your host), start with what to do in the first hour.
  • In WordPress, check Users first. Note down any unknown administrator, then delete it, reset every password and replace the secret keys (salts) in wp-config.php to log everyone out.
  • You have two ways back: restore a clean backup from before the attack, or clean the site by replacing files with official copies of the same version. Either way, update the plugin that let them in, or they will come back.
  • Don't rely on the dashboard's Re-install button. WordPress.org advises replacing the wp-admin and wp-includes folders by FTP, because the button only overwrites files and leaves added ones behind.
  • Security Ready does not clean hacked sites or remove malware. It can help afterwards by checking your plugin and theme versions against known vulnerabilities.

WordPress unknown admin user? Lock down users and wp-config.php

Do this work from a computer you have scanned for malware. Before you change anything, take one more copy of the site as it is now, files and database. WordPress.org recommends this snapshot even if it is infected: it is your reference for working out what happened, and a fallback if cleanup breaks something.

  1. 1

    Filter Users by Administrator

    Go to Users and click Administrator at the top. Look for names you don't know, former staff and old agency accounts. An admin you don't recognise is close to conclusive.

  2. 2

    Note it down, then delete it

    Write down the username and email address first. When you delete the user, WordPress asks what to do with their content. If the posts are not yours, delete them.

  3. 3

    Reset everyone's password

    All users, not just admins. Also change the passwords for your hosting control panel, FTP/SFTP and the database.

  4. 4

    Replace the secret keys (salts)

    Open the WordPress.org key generator, copy the eight new lines and paste them over the matching lines in wp-config.php. Everyone who is logged in, including the attacker, is signed out.

wp-config.php also holds your database password. Assume it was read: change the database password and update it in wp-config.php.

Restore a clean backup or clean the site?

Restoring a backup from before the attack is usually the fastest route. The catch is knowing when the attacker got in. Restore too recent a copy and the backdoor comes back with it.

Restore a backupClean the site
Best whenYou roughly know when the hack started and have a backup from before thatYou have no backup, or every backup is from after the attack
Watch out forPosts, orders and messages after the backup date are lost. You still need to update the entry pointMiss one hidden file and the hack returns. Slow, careful work

Ask your host how many days of backups they keep and whether you can restore files and the database yourself. If they only keep a week or two and the attacker has been in for longer, every copy may be infected. In that case, restore and then still work through the checks below.

Reinstall WordPress core the right way

Dashboard > Updates has a Re-install button. It is tempting, but WordPress.org's hacked-site guidance says not to use it after a hack: it overwrites existing files, and hacks often add new ones.

  1. 1

    Download the same version

    Dashboard > Updates shows your current version. Get exactly that version from the WordPress release archive. A different version can break the site.

  2. 2

    Replace wp-admin and wp-includes

    Using FTP/SFTP or your host's file manager, delete those two folders and upload the fresh ones. Replace the loose files in the root (index.php, wp-login.php and so on). Do not delete wp-config.php or wp-content.

  3. 3

    Open .htaccess

    WordPress.org calls it one of the files most often modified in a hack. Unknown redirects or long blocks of scrambled text are red flags.

If you or your developer can use the command line, WP-CLI's wp core verify-checksums compares your core files against WordPress.org's checksums.

WordPress malware removal: plugins, themes and the uploads folder

Next comes wp-content, where your themes, plugins and uploaded media live.

  • Plugins: delete anything you didn't install. Delete and reinstall the ones you need from WordPress.org, which also wipes code injected into their files. For premium plugins, download a fresh copy from the vendor.
  • Must-use plugins: files in wp-content/mu-plugins run automatically, can't be switched off from the dashboard and only appear under the Must-Use filter. One you didn't create is a warning sign.
  • Themes: delete themes you don't use. Compare the active one with a clean copy from its source. header.php, footer.php and functions.php are common targets.
  • Uploads: wp-content/uploads is for images and documents. A .php file in there is almost certainly a backdoor.

WordPress.org lists scanning plugins such as Wordfence and Sucuri. They catch a lot, but not everything. A clean scan is not proof the site is clean.

Check the database and scheduled tasks

A clean set of files can be reinfected by something left in the database or a scheduled task. This part can be handed to your developer.

  • Site address: in Settings > General, check that WordPress Address and Site Address are still yours. In the database these are siteurl and home in wp_options.
  • Active plugins: the active_plugins row in wp_options should not list anything you don't see on the Plugins screen.
  • Posts and pages: look for links or script tags you didn't add.
  • WP-Cron: the WP Crontrol plugin from WordPress.org lists every scheduled event and when it runs next. Ask your developer about any you don't recognise.
  • Server cron jobs: check the cron section of your hosting panel for jobs you didn't create.

Find the plugin that let them in

If you don't close the way in, expect to be hacked again within days. On WordPress, the entry point is usually an outdated plugin or theme, or a weak password.

  1. 1

    List your plugins and versions

    Tools > Site Health > Info has a button that copies the full list.

  2. 2

    Compare against known vulnerabilities

    Look up each plugin and version in our daily-updated WordPress plugin vulnerability list.

  3. 3

    Match the dates

    Ask your host for the access logs around the time the unknown admin or rogue files appeared. Repeated requests to one plugin's files often point to the entry point.

  4. 4

    Update everything, then change passwords again

    WordPress.org recommends a second password change once the site is clean, in case the first new passwords were captured during cleanup.

For the routine checks that keep this from happening again, see our WordPress security checklist.

When to hire a professional, and where Security Ready fits

Stop and bring in your developer or a specialist WordPress cleanup service if any of these apply:

  • The site handles customer data, such as orders or member accounts
  • You have no clean backup, or the hack keeps coming back after cleanup
  • FTP, databases and file managers are unfamiliar territory
  • You can't get into your hosting or domain account yourself

Security Ready does not clean hacked sites or remove malware. Where it helps is afterwards. On the Standard plan, the internal scan's WordPress plugin sends only the names and versions of your plugins and themes and checks them against known vulnerabilities. The external scan looks for open ports and files that should not be public.

No scan proves a site is safe. Vulnerabilities that haven't been published yet, and every backdoor already planted, are beyond what an automated scan can guarantee to find.

Frequently asked questions

Should I delete an unknown WordPress admin user right away?

Write down the username and email address first; you may need them to trace the attack or report it. Then delete the user, reset all other passwords and replace the secret keys in wp-config.php.

I'm locked out of wp-admin. What now?

Try the Lost your password link on the login screen. If the attacker changed your email address, WordPress.org explains how to fix it in the database through phpMyAdmin, then request a reset. If that is beyond you, ask your host or developer.

A security plugin found nothing. Am I done?

No. Scanners catch a lot, but not everything. Make sure you have also updated the vulnerable plugin, changed passwords a second time and checked the uploads and mu-plugins folders.

If I restore a backup, is the site fixed?

It looks fixed, but the plugin that let the attacker in comes back at its old version. Update everything right after restoring and change passwords again. Anything added after the backup date is lost.

How do I get rid of Google's "dangerous site" warning?

Once everything is fixed, request a review from Google Search Console. Our guide to what to do when your website is hacked covers the steps.

Can Security Ready remove the malware for me?

No. We don't do cleanup or malware removal. Use us afterwards to check plugin and theme versions and scan the site from outside. Your first full scan is free (one server per company, no payment details needed).

See where your own site stands — free

The free in-depth scan checks your site from the outside against thousands of known weaknesses and tells you how to fix each one. No payment details needed. For businesses; scans only with the owner's authorization.