Action hook 'activate_plugin'

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

View Source

activate_plugin

Action Hook
Description
Fires before a plugin is activated. If a plugin is silently activated (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 688

Hook Parameters

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

Usage Examples

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

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

Source Code Context

wp-admin/includes/plugin.php:688 - How this hook is used in WordPress core
<?php
 683  			 *
 684  			 * @param string $plugin       Path to the plugin file relative to the plugins directory.
 685  			 * @param bool   $network_wide Whether to enable the plugin for all sites in the network
 686  			 *                             or just the current site. Multisite only. Default false.
 687  			 */
 688  			do_action( 'activate_plugin', $plugin, $network_wide );
 689  
 690  			/**
 691  			 * Fires as a specific plugin is being activated.
 692  			 *
 693  			 * This hook is the "activation" hook used internally by register_activation_hook().

PHP Documentation

<?php
/**
			 * Fires before a plugin is activated.
			 *
			 * If a plugin is silently activated (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_wide Whether to enable the plugin 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.