Title: is_plugin_active
Last modified: August 19, 2016

---

# is_plugin_active

 *  Resolved [mme](https://wordpress.org/support/users/mme/)
 * (@mme)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/is_plugin_active/)
 * Hi,
 * I keep getting this error when putting this in my plugin:
 * > Fatal error: Call to undefined function is_plugin_active() in /home/xxxx/xx
 *     ```
       if (is_plugin_active('wplite/wplite.php')) {
       wp_get_current_user();
       if ($current_user->user_login=="Webmaster") {
       remove_action('admin_menu', 'wplite_disable_menus');
       remove_action('admin_head', 'wplite_disable_metas');
       }}
       ```
   
 * Why is this happening?

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [billseymour](https://wordpress.org/support/users/billseymour/)
 * (@billseymour)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709885)
 * +1 I am getting the same Fatal error. Also, I don’t see is_plugin_active in functions.
   php for WP v3.0.1. Has this function been eliminated from this latest WP version?–
   Bill
 *  Thread Starter [mme](https://wordpress.org/support/users/mme/)
 * (@mme)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709886)
 * Hi,
 * I have found a website that shows a workaround maybe not the best but it works:
 * [http://webdesign.onyou.ch/2010/07/28/check-if-a-wordpress-plugin-is-active/](http://webdesign.onyou.ch/2010/07/28/check-if-a-wordpress-plugin-is-active/)
 * Thanks,
 * mme
 *  [billseymour](https://wordpress.org/support/users/billseymour/)
 * (@billseymour)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709887)
 * Mme-
    Great- thanks for sharing your find.
 * I am checking several plugins, so I’m using a variable to allow the code to be
   repeated (changing only the var $plugin_var name being tested).
 *     ```
       <?php
         $plugin_var= "relevanssi";
         if (in_array( $plugin_var.'/'.$plugin_var.'.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) echo " (active plugin: ".$plugin_var.")";
       ?>
       ```
   
 * This solution works just fine. Thanks! –Bill
 *  Thread Starter [mme](https://wordpress.org/support/users/mme/)
 * (@mme)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709888)
 * You would probably be better off making a function of it then:
 *     ```
       <?php
       function plugin_is_active($plugin_var) {return in_array( $plugin_var. '/' .$plugin_var. '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); }
       ?>
       ```
   
 * This code is untested so it may contain some errors.
 * Place in the ‘functions.php’ in your theme file.
 * to run just call the following:
 * `plugin_is_active('plugin_name')`
 * Hope that helps,
 * Regards,
 * mmd
 *  [billseymour](https://wordpress.org/support/users/billseymour/)
 * (@billseymour)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709889)
 * Mme-
    Good idea, a function is definitely more flexible (and reusable). Your 
   function code works as written; I just added a temporary variable to be assigned
   the in_array function, and then be returned by function plugin_is_active.
 *     ```
       <?php
         function plugin_is_active($plugin_var) {
           $return_var = in_array( $plugin_var. '/' .$plugin_var. '.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
           return $return_var;
         }
       ?>
       ```
   
 * Appreciate your references and ideas. –Bill
 *  [saphod](https://wordpress.org/support/users/saphod/)
 * (@saphod)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709943)
 * Thanks for the function, which was exactly what I needed, since the is_plugin_active()
   function from WordPress led to a fatal error.
 * One suggestion, though: I reckon the function will not find plugins that are 
   located in a subdirectory with a different name as the actual php-file, e.g. “
   disqus-comment-system/disqus.php”.
 * I changed it to this (very simple):
 *     ```
       <?php
         function plugin_is_active($plugin_path) {
           $return_var = in_array( $plugin_path, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
           return $return_var;
         }
       ?>
       ```
   
 * You’ll have to provide the complete relatve path within your plugins-directory
   e.g. as the aforementioned “disqus-comment-system/disqus.php”.
 *  [Philip Arthur Moore](https://wordpress.org/support/users/philiparthurmoore/)
 * (@philiparthurmoore)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709970)
 * I also received a similar fatal error and instead of writing a new function from
   scratch I opened `/wp-admin/includes/plugin.php` and copy/pasted (and prefixed)
   the function code for `is_plugin_active` into my theme’s `functions.php` file:
 *     ```
       function mythemename_is_plugin_active( $plugin ) {
           return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
       }
       ```
   
 * And the code I used to call it:
 *     ```
       if ( mythemename_is_plugin_active('plugin-directory/plugin.php') )
           echo "ACTIVE";
       ```
   
 * Not all that different from some of the aforementioned solutions, but I thought
   it’d be nice to mention.
 *  [Frank P. Walentynowicz](https://wordpress.org/support/users/frankpw/)
 * (@frankpw)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709986)
 * It is important to understand when this fatal error occurs. The Codex clearly
   states that this function is available within admin pages only. This is why checking
   if plugin in question is in the resulting array of get_option( ‘active_plugins’)
   should be a preferred method.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘is_plugin_active’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 5 participants
 * Last reply from: [Frank P. Walentynowicz](https://wordpress.org/support/users/frankpw/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/is_plugin_active/#post-1709986)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
