WordPress action hook · part of WordPress core
deactivated_plugin
A WordPress core action that 6 plugins also fire themselves, running on 912K+ sites between them.
How to use deactivated_plugin
It's an action: your callback runs at that point and receives 2 arguments. Nothing needs to be returned.
Add this to your theme's functions.php or a small custom plugin:
add_action( 'deactivated_plugin', function( $plugin, $network_wide ) {
// Your code runs here.
}, 10, 2 );Argument names come from Plugin Dependencies's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
6 plugins that fire deactivated_plugin
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
W3 Total Cache900,000+ installs
do_action( 'deactivated_plugin', W3TC_FILE )Util_Activation.php:40 -
Lockdown WP Admin10,000+ installs
do_action( 'deactivated_plugin', LD_FILE_NAME )no-wpmu.php:60 -
Cowboy MCP2,000+ installs
do_action( 'deactivated_plugin', $plugin, true )includes/class-mcp-compat.php:271 -
Plugin Dependencies100+ installs
do_action( 'deactivated_plugin', $plugin, $network_wide )plugin-dependencies.php:541 -
CoCeCa10+ installs
do_action( 'deactivated_plugin', $plugin, $network_wide )includes/plugin-dependencies.php:530 -
Remote Control PanelFewer than 10 installs
do_action( 'deactivated_plugin', trim( $plugin) )remotecontrolpanel_plugins.php:225
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.