activate_{$plugin}
Action HookDescription
Fires as a specific plugin is being activated. This hook is the "activation" hook used internally by register_activation_hook(). The dynamic portion of the hook name, `$plugin`, refers to the plugin basename. 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 | 703 |
Hook Parameters
Type | Name | Description |
---|---|---|
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, 1);
function my_custom_function($network_wide) {
// Your custom code here
}
Source Code Context
wp-admin/includes/plugin.php:703
- How this hook is used in WordPress core
<?php
698 * @since 2.0.0
699 *
700 * @param bool $network_wide Whether to enable the plugin for all sites in the network
701 * or just the current site. Multisite only. Default false.
702 */
703 do_action( "activate_{$plugin}", $network_wide );
704 }
705
706 if ( $network_wide ) {
707 $current = get_site_option( 'active_sitewide_plugins', array() );
708 $current[ $plugin ] = time();
PHP Documentation
<?php
/**
* Fires as a specific plugin is being activated.
*
* This hook is the "activation" hook used internally by register_activation_hook().
* The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
*
* If a plugin is silently activated (such as during an update), this hook does not fire.
*
* @since 2.0.0
*
* @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: 1
- File: wp-admin/includes/plugin.php
Related Hooks
Related hooks will be displayed here in future updates.