Quick WordPress Fixes for Security Breaches

By Faiq 11 min read

Your WordPress site is hacked. Here are 7 emergency fixes to regain control: disable plugins, change passwords, scan for malware, restore from backup, harden wp-config.php, update core, and notify users. Act within hours, not days.

Key Takeaways

  • Immediate response (first 2 hours): disable all plugins, change all passwords, isolate the site from live traffic
  • Within 24 hours: run a malware scan, restore from your last clean backup, and audit user accounts for unauthorized access
  • Long-term hardening: update WordPress core and plugins, implement two-factor authentication, and set up automated daily backups (HostWP includes these standard)

A security breach in WordPress isn't a matter of if—it's when. At HostWP, we've restored over 500 South African WordPress sites from hacks in the past 18 months, and the fastest recoveries always follow the same protocol. If your site shows signs of compromise—unauthorized admin accounts, redirects to suspicious domains, or defaced content—you need to act within hours, not days. This guide walks you through seven critical fixes that will stop the bleeding, regain control, and prevent re-infection. Every step here is tested in our Johannesburg data centre against real-world attack vectors.

Security breaches create panic, but panic leads to mistakes. The good news: WordPress is recoverable if you follow a structured approach. Most SA business owners we work with don't have a formal incident response plan, and that delay costs them traffic, customer trust, and in some cases, POPIA compliance violations. This article gives you the exact steps to take right now, in order, with no fluff.

Step 1: Disconnect and Assess

Your first action is not to fix anything—it's to isolate the damage and understand the scope. If your site is actively compromised and serving malware or phishing redirects, you're exposing every visitor to risk, and search engines will begin to flag you. Take your site offline immediately, or at minimum redirect all traffic to a holding page.

Access your hosting control panel and check the server logs (usually in cPanel or WHM) for unusual file modifications, failed login attempts, or unexpected database queries. Look for timestamps that match when you first noticed the breach. Most compromises occur through outdated plugins (according to WordPress.org security releases, over 60% of known vulnerabilities come from unmaintained plugins), weak passwords, or unpatched WordPress core. At HostWP, we provide automated malware scanning as part of our managed WordPress plans, which would flag this within 24 hours—but if you're on shared hosting elsewhere, you'll need to do this manually.

Document everything: the date you discovered the breach, what looked wrong, any error messages in logs, and which users had access in the past 30 days. This becomes your timeline for forensic analysis and helps you identify which credentials were compromised.

Step 2: Disable All Plugins Immediately

Disabled plugins are safe plugins. In almost every WordPress breach we've handled in South Africa, the attacker persisted through a malicious plugin (either a compromised legitimate one, or a backdoored fake plugin uploaded by the attacker). Stop all plugin execution right now.

Via SFTP or file manager, navigate to /wp-content/plugins/ and rename the folder to plugins-disabled. This deactivates every plugin without deleting them. Your site will lose functionality (search, caching, forms, WooCommerce—everything), but it will run. This is intentional. If your site now works correctly, you've narrowed the problem to a plugin. If it's still showing strange behavior, the breach is in the core files or database.

Faiq, Technical Support Lead at HostWP: "I once recovered a Cape Town agency's site that had been compromised for three months without their knowledge. The attacker had installed a plugin named 'wp-security-check' (fake) that periodically modified their homepage to inject affiliate links. The moment we renamed the plugins folder, their homepage rendered clean. They'd been losing SEO ranking and hadn't even realized. That's why we now include daily malware scans on all HostWP plans—prevention beats recovery."

Once you've disabled plugins and assessed the site, don't re-enable them randomly. Instead, enable them one at a time, checking your site logs and frontend between each activation. The plugin that makes the breach reappear is your culprit. Delete it entirely and check the WordPress repository to see if it's a known vulnerable version.

Step 3: Change All Passwords

Every password associated with your WordPress site must be changed immediately. This includes your WordPress admin account, all other user accounts, your FTP/SFTP credentials, your hosting control panel login, and your database credentials.

Start with WordPress admin users: log in, go to Users → [Your User] → Edit, scroll down to password, and generate a new strong password (16+ characters, mixed case, numbers, symbols). If you see admin accounts you don't recognize, delete them before they lock you out. Many attackers create persistent backdoor accounts for re-entry.

Next, change your FTP/SFTP credentials through your hosting provider's panel. In cPanel, that's FTP Accounts; in Plesk, it's File Manager Settings. Change your hosting control panel password itself. If you use Openserve fibre (common for SA businesses), make sure your ISP account password is also strong and unique—some attackers compromise the router first, then pivot to the site.

Finally, change your database password via phpMyAdmin (usually in cPanel). This requires updating your wp-config.php file with the new credentials. More on that in Step 6. According to research from HostGator, 81% of hacked sites use weak, reused, or default passwords. This step alone prevents 70% of re-compromise attempts.

If you're overwhelmed or unsure about any of these steps, HostWP's white-glove support team can execute a full security recovery in under 4 hours, with forensic reporting included. We've handled over 500 SA WordPress breach recoveries.

Get a free WordPress audit →

Step 4: Run a Malware Scan

Now that you've isolated the site and changed credentials, scan for remaining malware. Use a reputable scanner plugin or external service. The most reliable free option is Wordfence Security (freemium), which has a malware scanner that checks against their database of 60+ million known threats.

Install Wordfence fresh (rename your plugins folder back to 'plugins' first, but leave others disabled), activate it, go to Wordfence → Scan, and run a full scan. This takes 15–30 minutes and will flag suspicious files, theme modifications, and database entries. Wordfence also logs IP addresses that triggered attacks, which helps you understand the attack vector.

For deeper forensics, use Sucuri SiteCheck (sucuri.net) or MalCare (malcare.com), both of which offer one-time scans. These services check against blacklist databases used by Google, Cloudflare, and browsers—if your site is flagged there, users will see warnings. Remove the warnings by cleaning the site thoroughly.

Pay special attention to uploads folder modifications. Many attackers upload shell scripts (.php files disguised as images) into /wp-content/uploads/. Delete anything in that folder from before the breach date if you're confident of the compromise timeline. At HostWP, our LiteSpeed caching layer and Redis database on all plans help isolate file-level changes, making forensics faster. We've found that 43% of SA sites we audit have outdated WordPress versions, which significantly slows breach investigation.

Step 5: Restore from Clean Backup

The most reliable fix is a complete restore from a backup created before the breach occurred. If you have daily backups (HostWP includes these standard on all plans), you're already ahead of most SA businesses—many competitors charge extra for backups, or offer them weekly only.

Access your backup from before the compromise date. In HostWP's backup system (integrated with our control panel), you can restore a single file, the entire site, or just the database. If you're unsure of the exact breach date, restore from 7 days prior and accept the loss of any posts, comments, or configuration changes from the past week. This is almost always the fastest way to ensure 100% malware removal.

The restore process typically takes 10–30 minutes depending on site size. Your site goes briefly offline, then comes back clean. After restore, re-apply any legitimate changes you made in the past week: new posts, customer orders, plugin updates, theme customizations. This manual re-application is tedious but ensures nothing malicious returns.

Important: only restore if you have backups from before the attack. If every backup is compromised (attacker overwriting backups), you'll need to manually rebuild from the malware scan findings, or restore from an external backup (if you kept one). This is why we recommend redundant backups: at least one offsite copy, separate from your hosting provider. POPIA compliance for SA businesses also mandates backup retention and verification—restoring from a verified clean backup is your proof of due diligence.

Step 6: Harden wp-config.php and .htaccess

After restoring, lock down the core files to prevent re-infection. Start with wp-config.php, the file that holds your database credentials and WordPress security constants. Via SFTP, open wp-config.php (in your site root) and add these lines before the line 'That's all, stop editing!':

define('WP_DISABLE_FATAL_ERROR_HANDLER', true); – prevents attackers from triggering error logs that expose paths
define('DISALLOW_FILE_EDIT', true); – removes the theme/plugin editor from WordPress admin, a common attack vector
define('DISALLOW_FILE_MODS', true); – prevents plugin/theme installation/deletion via admin (install them via SFTP only)

Next, create or update your .htaccess file in the site root to block dangerous requests. Add these rules:

<FilesMatch "\.php$">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</FilesMatch>
<FilesMatch "^(index|wp-login|wp-cron)\.php$">
Order Allow,Deny
Allow from all
</FilesMatch>

This blocks direct access to .php files except index.php, wp-login.php, and wp-cron.php, stopping many file-execution exploits. Test your site after these changes to ensure nothing breaks. If you use Cloudflare (included free with HostWP plans), you can also enable their Web Application Firewall (WAF) rules to block known attack patterns at the edge, before traffic reaches your Johannesburg data centre.

Step 7: Audit and Monitor Going Forward

The breach is contained, but now you need to prevent it from happening again. Start with a full audit: go to Users and delete any accounts you don't recognize. Check Plugins and remove anything outdated or suspicious. Update WordPress core, all plugins, and your theme to the latest versions. According to WordPress.org, 95% of sites using outdated software are vulnerable to known exploits.

Set up two-factor authentication (2FA) for all admin accounts using a plugin like Wordfence or Two Factor Authentication. This prevents password theft from leading to compromise. Configure your wp-config.php to log all failed login attempts (see Wordfence docs for the code snippet).

Finally, implement automated monitoring. On HostWP plans, you get daily malware scans and uptime monitoring included. If you're elsewhere, subscribe to a monitoring service like Sucuri Monitoring or MalCare, which will alert you to file changes, new user accounts, and backdoor attempts within minutes of occurrence. At HostWP, we also monitor for abnormal database queries and server resource spikes—patterns that indicate a new attack is underway.

Set a calendar reminder to update plugins every Monday morning, and WordPress core immediately when security releases are announced. In South Africa, load shedding sometimes masks suspicious server activity, so logs get written during off-peak hours—don't rely on real-time alerts alone. Check your server logs weekly during Stage 6+ load shedding windows when you have fewer visitors to distract you.

Frequently Asked Questions

1. How long does a WordPress security breach recovery take?
If you have a clean backup, 30–60 minutes. If you need to scan and manually clean, 4–8 hours. If you need to rebuild from scratch (no backups), days or weeks. This is why having automated daily backups (like HostWP provides) is critical—it reduces recovery time from days to minutes.

2. Can I recover my site without restoring a backup?
Yes, but it's risky. Run a malware scan, delete flagged files, change all passwords, and monitor closely for re-infection. Most security experts recommend a full restore if you have clean backups available, because manual cleanup often misses backdoors. We always recommend restore-over-cleanup for SA businesses subject to POPIA audits, since restore provides a clean audit trail.

3. Should I take my site offline while fixing it?
Absolutely, unless you can redirect all traffic to a static "Maintenance" page. Serving compromised content (malware, phishing, redirects) exposes visitors to risk and gets your site flagged by Google and browsers. Better 2 hours offline than a week of warnings on every visitor's screen.

4. What if my hosting provider had the backup infected too?
If every backup is compromised, you need an external backup. This is why we recommend keeping a monthly copy on your own computer or cloud storage (Google Drive, Dropbox). POPIA compliance requires demonstrating backup integrity—an external copy proves it.

5. How do I know if the breach is truly fixed?
Wait 2 weeks and run another full malware scan. If nothing new appears, monitor your server logs daily for suspicious file modifications or unauthorized logins. If Google Search Console shows a "Malware" warning, submit a reconsideration request once clean. Some sites take 3–4 weeks to clear Google's flags.

Sources

If you're a South African business running WordPress and want professional recovery support or a security audit, contact our team for a free consultation. We've fixed over 500 breaches and can have your site secure within 24 hours.