Disabling a Single Plugin Through the Database

If you've reached it here you've made it pretty far and I'm guessing you just want to learn more. I didn't wanted to include this on the main post page as its quite in-depth. I will show and try to explain how you can disable a single plugin (or one by one) through the database method.

Here's what my current option value looks like on my development site;


For your site it will likely be a lot longer, on my development site there are currently only 6 plugins enabled.

This is a array that has been serialized for storage. To extract a single value from here you'd have to be very precise, removing a character too much or little can make the value invalid, resulting in all plugins being disabled on your site.

If you study the string very closely you may already find a pattern in there. Luckily serialization is nothing too complicated, it has a consistent and known pattern. Let me break down how this is build up.


Each selected row in there is a plugin item (plugin) in the array. Above and below the rows is the markup for a array with 6 items in there (the a:6: indicates there are 6 items to follow). Breaking one individual item down further;

i:1; s:26:"keyboard-action/plugin.php";

In here it shows that the first parts it expects a integer which is followed by the integer value 1. The second section expects a string followed by the length of the string, followed by the actual string.

To Deactivate a Plugin

To remove a plugin from the option value there you'd need to modify two things. (A) remove the plugin from the list, (B) change the expected number of items in the array accordingly. Here's an example where I highlight what I've changed.


Thats it! Now save the value and the removed plugin will be deactivated and not loaded anymore.

I hope that has taught you something useful!

About the author: Jeroen Sormani is actively building WordPress, WooCommerce and Easy Digital Downloads plugins. Slightly obsessed by writing high quality code.
Follow Jeroen on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *