Activate WordPress Plugins Via The Database

Activate WordPress Plugins Via The Database
Do you want to activate WordPress plugins from the database? This term is new yet interesting to learn. And if you are looking for an answer that is it possible to turn on plugin via the database, so it is YES!

This blog will be interesting, here we explain how you can enable plugins via the database. Here to be noted, you cannot do this on the live site. This method is introducing for experimenting in case of getting hacked or whatever the situation of emergency is. To do this quickly, you have an easy option to go to the plugin portal in WP Admin Area. If you activate the plugin, this may not work properly.

So, here first you will need to understand what it is and how you can do it quickly.
The database is important, but before doing any changes in WordPress first you have to learn the basics so you can do everything easily.

Even with this, you will prepare for everything, if anything happens wrong. Also, check if your database contains some useful information, take its backup first. Just in case if anything goes wrong, you can get back on your work without worrying.

In this guide, we will share the step-by-step guide on how to activate WordPress plugins. In this, we have modified an option in WordPress table with Active_plugins, and it is a serialized array contains great information that currently active.

With this plugin array, you can easily get to know which plugin is active. It is a basic idea, so let us go in detail now and see how it will be done.

First, we will start to form the general concept then we will learn it with a suitable example.
General Method

To activate the plugin, follow the given steps:

Step One: Copy The Active_Plugins Array

For copy the plugins, you need a tool as in phpMyAdmin, here you have to enter the following command:

SELECT* FROM wp_options WHERE option_name=’active_plugins’

Keep in mind one thing, you have to edit the default table prefix, wp_ with matching configuration as you want. Once this query activates, copy the value active_plugins. Well, the copied value depends on how many active plugins you have to copy. This will look like a given example:

A:4: {i:0;s:19:”Akismet.php”;i:3;s:45:”dashboard-widgets-suite/dashboard-widgets.php”;
i:4;s;33:”disable-embeds/disable-embeds.php:”user-submitted-posts/user-submitted-posts.php”;}

This may look difficult for you, but this is exactly what you see. And it is an ordinary serialized array. With an above-given example, you can see this array has 4 plugins that are currently activated. If you have large numbers of arrays, it will go further. If we want to add another one, so it will go to 5. And there will be 5 active_plugins.

Step Two: Disclose The Active_Plugins

In this step, we want to disclose the plugins array. Hence, this would look like a given example:

A:5;{
i:0;s:19: “Akismet/Akismet.php”;
i:1;s:43:”dashboard-widgets-suite/dashboard-widgets.php”;
i:2;s:31:”disable-embeds-disable/disable-embeds.php”;
i:3;s:32:”disable-emojis/diable-emojis.php”;

These arrays will continue to rise until 5. Remember one thing, this information is about our WordPress database, you may find long or fewer arrays as you have active_plugins.
I hope this is getting clear to you. Now, notice everything in an array which represents active_plugins, that is denoted as I:n;,.

N-unique integer (1,2,3….)
And the array denoted as s:x:;
x- Numbers of characters contain.

For example- I:8;s;45:”user-submitted-posts/user-submitted-posts.php”;
Suppose, 8 is the last item in the array so it has index 9 and the string value is 45 characters. It is one of the active active_plugins.

Step Three- Adding More Plugin To An Array

In this step, we will add the next plugin to the active_plugin to the array. So to start with this, see the example:

I:6;s:33:”my-plugin-name/my-plugin-name.php”;

Now, we have increased the numbers of the index by 1. Hence we have, i:6; and then we have counted the numbers of characters “slug”. It is the name of the plugin directory followed with a slash (/) and the plugin file.

So, once completed with an array file, we need to add it to another array such as:

i:0;s:19: “Akismet/Akismet.php”;
i:1;s:43:”dashboard-widgets-suite/dashboard-widgets.php”;
i:2;s:39:”disable-embeds-disable/disable-embeds.php”;
i:3;s:38:”disable-emojis/diable-emojis.php”;
i:4;s:36:”disable-wp-rest-api/disable-wp-rest-api.php”;
i:5;s;;32:”my-plugin-name/my-plugin-name.php”;

As you can see, the index values are in ascending order. The value looks good with correct syntax and so on. We have added the value to an array that counts a:5. Because we have now 6 items in the array with little modification.

i:0;s:19: “Akismet/Akismet.php”;
i:1;s:43:”dashboard-widgets-suite/dashboard-widgets.php”;
i:2;s:39:”disable-embeds-disable/disable-embeds.php”;
i:3;s:38:”disable-emojis/diable-emojis.php”;
i:4;s:36:”disable-wp-rest-api/disable-wp-rest-api.php”;
i:5;s;;32:”my-plugin-name/my-plugin-name.php”;

Congratulations! The array is done. But there are still some mistakes which we need to clear. There is whitespace that you need to remove, which we used while creating an array. To do this, you have one tool that erases whitespaces from the array. Just like an example:

A:6: {i:0;s:19:”Akismet.php”;i:3;s:45:”dashboard-widgets-suite/dashboard-widgets.php”;
i:4;s;33:”disable-embeds/disable-embeds.php:”user-submitted-posts/user-submitted-posts.php”;}

It is all set for the database.

Step Four- Activate The Active-Plugins

You have done with an array, now its time to activate WordPress plugins from the database. Update the plugins with the modified version. Once the replacement is done, you can see the Active_plugins in your WP-Admin area with 5 plugins.

Activation

After the troubleshooting and updating the Active_plugins array, just in case you find ZERO plugins are activated, so this sounds a mistake in the array or syntax or characters. This may be of a semicolon, bracket, space or anyone. One single mistake can spoil your hard work, so it’s better to do this calmly. If you find mistakes, correct them or rework on arrays.

Examples:

We have covered every detail of general serialized array, now it’s time to learn it with examples. Let us get started!

Suppose we need to activate the Banhammer, which has several plugins as well. so, first I will do copy the value of active_plugins from the database.
A:2:{I:0;s:39:”block-bad-queries/block-bad-queries.php”;i:1;s:45: :”dashboard-widgets-suite/dashboard-widgets.php”;

Next, I will prepare the array for this plugin, for example:

I:2;s:23:”Banhammer/Banhammer.php”;

Here you can see, I give index 2 because it will be the third array. S, value 23 characters, string path. You may notice here, zero white spaces that we are going to add in active_plugin array. See example.

A:3:{I;0;s;39:” block-bad-queries/block-bad-queries.php”;i:1;s:45: :”dashboard-widgets-suite/dashboard-widgets.php”; 
I:2;s:23:”Banhammer/Banhammer.php”;}

Are you clear now? This quite easy, but yes you have to go perfectly in every set in options_table. Once you understand how this actually works, you can do it.

Related Post: How to Deactivate WordPress plugins without accessing wp-admin

About Shri Posts

Shri shares exciting WordPress themes, plugins and other WordPress related news for our viewers. He also posts selected WordPress developers interviews from time to time.

SKT Free Software Theme