Action hook 'deactivate_plugin'

in WP Core File wp-admin/includes/plugin.php at line 787

View Source

deactivate_plugin

Action Hook
Description
Fires before a plugin is deactivated. If a plugin is silently deactivated (such as during an update), this hook does not fire.

Hook Information

File Location wp-admin/includes/plugin.php View on GitHub
Hook Type Action
Line Number 787

Hook Parameters

Type Name Description
string $plugin Path to the plugin file relative to the plugins directory.
bool $network_deactivating Whether the plugin is deactivated for all sites in the network or just the current site. Multisite only. Default false.

Usage Examples

Basic Usage
<?php
// Hook into deactivate_plugin
add_action('deactivate_plugin', 'my_custom_function', 10, 2);

function my_custom_function($plugin, $network_deactivating) {
    // Your custom code here
}

Source Code Context

wp-admin/includes/plugin.php:787 - How this hook is used in WordPress core
<?php
 782  			 *
 783  			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
 784  			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
 785  			 *                                     or just the current site. Multisite only. Default false.
 786  			 */
 787  			do_action( 'deactivate_plugin', $plugin, $network_deactivating );
 788  		}
 789  
 790  		if ( false !== $network_wide ) {
 791  			if ( is_plugin_active_for_network( $plugin ) ) {
 792  				$do_network = true;

PHP Documentation

<?php
/**
			 * Fires before a plugin is deactivated.
			 *
			 * If a plugin is silently deactivated (such as during an update),
			 * this hook does not fire.
			 *
			 * @since 2.9.0
			 *
			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
			 *                                     or just the current site. Multisite only. Default false.
			 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-admin/includes/plugin.php
Related Hooks

Related hooks will be displayed here in future updates.