How to Prevent a WP Website Lockout With "Critical Errors"
WordPress will lock you out of your site if one of your plugins has a critical error. This makes it tough to fix the issue. You'll need to get FTP access to disable the plugin(s) responsible, and depending on your server setup, this may be fairly complicated. In some organizations, you'll need to go through several chains of command to get the site working again.
I put together this script to temporarily disable all WordPress plugins in the event of an emergency, which will help you regain access to your /wp-admin/ dashboard.
This requires the admin to be currently signed into WordPress in order for this to work. This is perfect for situations where a plugin update just broke your site and it's displaying the classic error:
"There has been a critical error on this website. Please check your site admin email inbox for instructions.
Learn more about troubleshooting WordPress."
If your site breaks and you see this warning after updating a plugin, you can load this script and all plugins will be disabled, then you can start re-enabling them one by one until you find the culprit.
Simply upload this to your WordPress folder and name it something that you'll remember. You can also set a password on this file in-case somebody happens to stumble across it:
<?php
$secret_password = 'YourSecretPassword';
require_once('wp-load.php');
if (!isset($_GET['password']) || $_GET['password'] !== $secret_password) {
die('Access denied: Incorrect or no password provided.');
}
update_option('active_plugins', array());
echo 'All plugins have been disabled.';
Let's say you name it "disable-plugins.php". When you visit it, you would add the password to it, like this:
yourdomain.com/disable-plugins.php?YourSecretPassword
You should get a message that all plugins have been disabled, and your access to your WordPress site is restored.
If you don't have FTP access, you can upload this PHP file with a plugin like File Manager for WordPress.
It may not come in handy right away, but when you're locked out of your site, you'll be happy you had this handy little script! Please let me know what you think in the comments.
October 10, 2024
is it just me or does ftp access seem pretty complicated to everyone else too? it's often tough for me! 😅
October 16, 2024
Hey Curtis!
For sure FTP access can sometimes be really difficult! You're definitely not the only one who feels this way. I've seen quite a few clients have an easier time when they use more user-friendly FTP clients. Have you tried using any of those yet?
Please let me know if you need any more tips!