Skip to content
    Guide

    What to do if your WordPress site is hacked

    Last updated

    Finding out a site has been hacked is stressful, but most hacks can be cleaned up fully if you work through them in order. The common signs are a Malware Detected alert, visitors being redirected to spam or scam sites, strange new pages or administrator accounts, a warning from Google or your host, or a sudden slowdown.

    This guide is a step-by-step plan using the tools in MaintainHQ. Follow it in order. The most common mistake is rushing to restore a backup before you know how the attacker got in, which simply lets them back in.

    Step 1: Keep the evidence

    Before changing anything, take a fresh backup. It records the site exactly as the attacker left it, which helps you find what changed and when.

    1. Open Backups in the left-hand menu and press Backup Now.
    2. Choose the site and Full site, then press Start Backup.
    3. When it shows Completed in History, pin it so it is not cleared away.

    Do not restore over the site yet, and do not delete files at random.

    Step 2: Lock the attacker out of accounts

    Change passwords early, so the attacker cannot simply log back in while you work:

    • Every WordPress administrator password.
    • Your hosting control panel, SFTP and database passwords (from your host).
    • Your own MaintainHQ password, and turn on two-factor authentication under Profile if it is not on.

    If an administrator is locked out because the attacker changed their password, use Emergency reset on the site’s Security tab to sign them out everywhere and give them a single-use sign-in link. See hardening, firewall and two-factor sign-in.

    Turn on the firewall for the site now if it is off.

    Step 3: Find what has been changed

    1. Open Security in the left-hand menu, choose the Malware scan tab and pick the site.
    2. Press Scan now and wait for it to finish.
    3. Open Details on each Critical or High finding. Note the file or location, the matched code and the First seen date.
    4. On the site’s Security tab, check the Known vulnerabilities card. An out-of-date plugin with a known hole is the most likely way in.
    5. Look at the site’s Activity log in MaintainHQ, and at the Users screen in WordPress, for logins and administrator accounts nobody recognises.

    The earliest First seen date tells you roughly when the hack happened. That matters when choosing a clean backup.

    Step 4: Clean the site or restore a clean backup

    You have two ways to remove the damage. Choose based on how much has changed since the hack began.

    Clean up or restore?
    Clean in placeRestore a clean backup
    Best whenThe hack is recent, or the site has taken orders or content sinceYou have a backup from before the First seen date and little has changed since
    HowReplace affected plugins and themes from trusted sources; remove unknown files and admin accountsRestore the whole site, or just the affected files and folders, from a backup taken before the hack
    RiskMissing a hidden fileLosing content added since the backup (the safety backup keeps a copy)

    Cleaning in place

    • Check each finding against a clean copy: the original plugin or theme, WordPress.org, or an older backup. Some findings are suspicious rather than proof.
    • Replace affected plugins and themes with fresh copies from trusted sources, instead of editing out lines.
    • Remove files and administrator accounts nobody recognises.

    Restoring

    Choose a backup taken before the earliest First seen date. To keep recent orders and content, restore only the affected files and folders (Browse files and tables in History) rather than the whole site. See restoring a backup.

    Step 5: Close the way in

    If you skip this step, the site is likely to be hacked again, often within days.

    • Install every security update, especially for anything on the Known vulnerabilities card. Remove plugins and themes you do not use.
    • Change the salts in wp-config.php (secret keys WordPress uses for logins), which signs everyone out, including the attacker.
    • On the WP Hardening tab, press Apply Recommended, and consider Disable File Editor and Disable PHP in Uploads if they are not already on.
    • Turn on two-factor sign-in for administrators.

    Step 6: Check, then keep watching

    1. Run the malware scan again. It should show no Critical or High findings. Findings that have gone are marked resolved.
    2. Visit the site as a visitor, including on a phone, and check for redirects or strange content.
    3. Take a fresh full backup and pin it as your clean starting point.
    4. Make sure the Malware Detected and Known Vulnerability alerts are on under Alert settings.
    5. If Google or your host flagged the site, ask them to review it now that it is clean.

    Finally, write down what happened, how they got in and what you changed. If the site belongs to a client, they will want to know, and a record helps if it happens again.

    Frequently asked questions

    Should I just restore yesterday’s backup?
    Only if yesterday’s backup is from before the hack, and only after you have changed passwords and fixed the way in. Hacks are often found weeks after they happen, so check the First seen dates in the malware scan first.
    Can Gus clean a hacked site for me?
    Gus can investigate the findings and prepare a fix. Every fix needs your approval, and if the site gets worse afterwards Gus rolls it back automatically.
    Will restoring remove the malware from the database?
    A whole-site restore replaces the entire database with the backup’s copy, so yes, if the backup is from before the hack. A partial restore only replaces the tables you choose.
    How do I stop it happening again?
    Keep software updated, delete unused plugins and themes, use the hardening settings and firewall, and turn on two-factor sign-in for administrators.

    Let MaintainHQ run the routine

    Updates with automatic rollback, backups, uptime, security checks and client reports, with Gus to fix what breaks.

    Start free trial

    From £29 a month for up to 2 sites. Every plan starts with a 14-day trial.