I'd like to query the database directly, and determine which plugins are enabled.

How can I do this?

3 Answers 3


You can do it like this:


SELECT * FROM wp_options WHERE option_name = 'active_plugins';

But for better approach will be the WordPress way:


if ( ! function_exists( 'get_plugins' ) ) {
    require_once ABSPATH . 'wp-admin/includes/plugin.php';

$active_plugins = get_option('active_plugins');
$all_plugins = get_plugins();
$activated_plugins = array();

foreach ($active_plugins as $plugin){           
         array_push($activated_plugins, $all_plugins[$plugin]);

Here is a solution that outputs the values in a human readable format:

mysql -h -u wordpress -p wordpress -ss --raw -N -e 'SELECT option_value FROM wp_options WHERE option_name="active_plugins"' | php -r "var_dump(unserialize(stream_get_contents(STDIN)));"
  • 1
    yeah it is stored in serialized format, so you had to unserialize it if directly accessing the database Commented Nov 23, 2017 at 12:31

You can use get_options('active_plugins') to retrieve all active plugins.

For checking against one plugin active or not you can use it like this :

if (in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )) { 
   //Woocommerce Active
   //Woocommerce Deactive
  • I'd like to query the database directly Commented Nov 23, 2017 at 12:25
  • it is located in wp_options table in field option_name = active_plugins Commented Nov 23, 2017 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.