Title: plugin activation error handling
Last modified: August 19, 2016

---

# plugin activation error handling

 *  [smurfdev](https://wordpress.org/support/users/smurfdev/)
 * (@smurfdev)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/plugin-activation-error-handling/)
 * Hi !
 * I could not find the answer to my newbie question in the codex so I ask here.
 * Within a plugin activation function, how to tell wordpress whether the plugin
   could be activated or not and if not how to display an error message whithin 
   the wordpres plugin management page ?
 * thanks

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

 *  [Technoh](https://wordpress.org/support/users/technoh/)
 * (@technoh)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457756)
 * I am looking for this information as well and it would be most welcome. If I 
   find something on other sites I will post it here as well.
 *  [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457802)
 * Yeah, I have the same dilemma 🙂 I’ve been digging around but had no luck!
 *  [macguru2000](https://wordpress.org/support/users/macguru2000/)
 * (@macguru2000)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457833)
 * I am looking for the same thing, especially a way to detect a Network Activate
   and stop users from activating [my plugin](http://wordpress.org/extend/plugins/catablog)
   that way, anyone have any ideas?
 *  [ugosinhache](https://wordpress.org/support/users/camaleo/)
 * (@camaleo)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457834)
 * Hi,
 * I also cannot find a way to tell wordpress whether the plugin could be activated.
 * However I am about to release a new version of [myEASYbackup](http://myeasywp.com/plugins/myeasybackup/)
   and added the following code at the beginning of the main script:
 *     ```
       if(is_admin() && version_compare(PHP_VERSION, '5', '<')) {
   
       	/**
       	 * @since 1.0.5.6
       	 */
       	function myeasy_min_reqs() {
   
       		echo '<div class="error">'
       				. '<h3>' . __( 'Warning! It is not possible to activate this plugin as it requires PHP5 and on this server the PHP version installed is: ', MEBAK_LOCALE )
       					. '<b>'.PHP_VERSION.'</b></h3>'
       				. '<h3><a href="http://www.php.net/releases/#v4" target="_blank">' . __( 'PHP4 was discontinued by the PHP development team on December, 31 2007 !!', MEBAK_LOCALE ) .'</a>'
       					. '</h3>'
       				. '<p>' . __( 'For security reasons we <b>warmly suggest</b> that you contact your hosting provider and ask to update your account to PHP5.', MEBAK_LOCALE )
       					. '</p>'
       				. '<p>' . __( 'If they refuse for whatever reason we suggest to <b>change provider as soon as possible</b>.', MEBAK_LOCALE )
       					. '</p>'
       			.'</div>'
       		;
   
       		$plugins = get_option('active_plugins');
       		$out = array();
       		foreach($plugins as $key => $val) {
   
       			if($val != 'myeasybackup/myeasybackup.php') {
   
       				$out[$key] = $val;
       			}
       		}
   
       		update_option('active_plugins', $out);
       	}
       	add_action('admin_head', 'myeasy_min_reqs');
   
       	return;
       }
       ```
   
 * Now, every time the plugin is activated, it will show a warning message and automatically
   deactivate itself.
 * Maybe not an elegant solution but it works.
 *  [ugosinhache](https://wordpress.org/support/users/camaleo/)
 * (@camaleo)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457835)
 * Sorry, I forgot some explanations.
 * The new version of my plugin requires PHP5 so,
 * If we are within the admin panel and the code is running on a previous PHP version:
   `
   if(is_admin() && version_compare(PHP_VERSION, '5', '<')) {`
 * I loop into the active plugins array:
    `foreach($plugins as $key => $val) {`
 * if its not my plugin:
    `if($val != 'myeasybackup/myeasybackup.php') {`
 * I copy the plugin in the output array:
    `$out[$key] = $val;`
 * then its simply matter to update the active_plugins option:
    `update_option('
   active_plugins', $out);`
 * Hope it helps and, if you find a better solution, please share it!

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

The topic ‘plugin activation error handling’ is closed to new replies.

 * 5 replies
 * 5 participants
 * Last reply from: [ugosinhache](https://wordpress.org/support/users/camaleo/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-activation-error-handling/#post-1457835)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
