Title: Error activating with WP-CLI
Last modified: March 9, 2017

---

# Error activating with WP-CLI

 *  [Mattia Migliorini](https://wordpress.org/support/users/deshack/)
 * (@deshack)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/error-activating-with-wp-cli/)
 * When activating the plugin using WP-CLI, it fails with a fatal error:
 *     ```
       PHP Fatal error:  Uncaught Error: Call to undefined function wpsl_add_roles() in /wp-content/plugins/wp-store-locator/inc/install.php:61
       Stack trace:
       #0 /wp-content/plugins/wp-store-locator/inc/install.php(36): wpsl_install_data()
       #1 /wp-content/plugins/wp-store-locator/wp-store-locator.php(114): wpsl_install(NULL)
       #2 /wp-includes/class-wp-hook.php(298): WP_Store_locator->install(NULL)
       #3 /wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)
       #4 /wp-includes/plugin.php(453): WP_Hook->do_action(Array)
       #5 /wp-admin/includes/plugin.php(591): do_action('activate_wp-sto...', NULL)
       #6 phar:///usr/local/bin/wp/php/commands/plugin.php(284): activate_plugin('wp-store-locato...', '', NULL)
       #7 phar:///usr/local/bin/wp/php/WP_CLI/CommandWithUpgrade.php(208): Plugin_Command->activate(Array)
       #8 phar:///usr/local/bin/wp/php/commands/plugin.php(682): WP_CLI\Comm in /wp-content/plugins/wp-store-locator/inc/install.php on line 61
       ```
   
 * Everything works fine via web.

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

 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/error-activating-with-wp-cli/#post-8893222)
 * I think I see why. I never used WP-CLI myself, so never checked it 🙁 But the
   roles.php is only included when is_admin is true, so there’s no check for WP-
   CLI.
 * If you don’t mind, can you try you replace this.
 * `if ( is_admin() ) {`
 * with the code below on [this](https://plugins.trac.wordpress.org/browser/wp-store-locator/tags/2.2.7/wp-store-locator.php#L86)
   line, and see if it then works fine?
 * `if ( is_admin() || defined( 'WP_CLI' ) && WP_CLI ) {`
 *  Thread Starter [Mattia Migliorini](https://wordpress.org/support/users/deshack/)
 * (@deshack)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/error-activating-with-wp-cli/#post-8894868)
 * Hi Tijmen,
    works fine with the fix provided!

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

The topic ‘Error activating with WP-CLI’ is closed to new replies.

 * ![](https://ps.w.org/wp-store-locator/assets/icon-256x256.jpg?rev=1007784)
 * [WP Store Locator](https://wordpress.org/plugins/wp-store-locator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-store-locator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-store-locator/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-store-locator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-store-locator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-store-locator/reviews/)

## Tags

 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)

 * 2 replies
 * 2 participants
 * Last reply from: [Mattia Migliorini](https://wordpress.org/support/users/deshack/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/error-activating-with-wp-cli/#post-8894868)
 * Status: not a support question