• Resolved Lana Codes

    (@lanacodes)


    I get the following error message:
    PHP Fatal error: Uncaught Error: Call to undefined function is_plugin_active()

    Here’s how to fix it:

    /**
     * check other plugin
     */
    function gf_cgfm_check_other_plugin() {
    
       /**
        * Ensure is_plugin_active() exists (not on frontend)
        */
       if ( ! function_exists( 'is_plugin_active' ) ) {
          include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
       }
    
       /**
        * Detect plugin WooCommerce Mailerlite
        */
       if ( ! is_plugin_active( 'woo-mailerlite/woo-mailerlite.php' ) ) {
          // Plugin is activated.
          require 'vendor/autoload.php';
       }
    }
    
    add_action( 'plugins_loaded', 'gf_cgfm_check_other_plugin' );

    You need to put the check in the plugins_loaded hook. And load the is_plugin_active function from core.

  • The topic ‘“undefined function is_plugin_active()” error report and fix howto’ is closed to new replies.