The network_plugin_loaded WordPress PHP action is used when a single network-activated plugin has finished loading.
Usage
add_action('network_plugin_loaded', 'your_function_name'); function your_function_name($network_plugin) { // your custom code here }
Parameters
$network_plugin
(string) – Full path to the plugin’s main file.
More information
See WordPress Developer Resources: network_plugin_loaded
Examples
Log network plugin loading
Log when a network plugin has loaded.
add_action('network_plugin_loaded', 'log_network_plugin_loaded'); function log_network_plugin_loaded($network_plugin) { error_log("Network plugin loaded: " . $network_plugin); }
Perform custom action when a specific network plugin is loaded
Perform a custom action when the ‘example-plugin’ network plugin is loaded.
add_action('network_plugin_loaded', 'custom_action_on_plugin_loaded'); function custom_action_on_plugin_loaded($network_plugin) { if (strpos($network_plugin, 'example-plugin') !== false) { // your custom code here } }
Modify plugin behavior on network plugin load
Modify the behavior of a specific network plugin when it is loaded.
add_action('network_plugin_loaded', 'modify_plugin_behavior'); function modify_plugin_behavior($network_plugin) { if (strpos($network_plugin, 'example-plugin') !== false) { // your custom code to modify plugin behavior here } }
Load custom CSS or JavaScript when a network plugin is loaded
Load custom CSS or JavaScript when a specific network plugin is loaded.
add_action('network_plugin_loaded', 'load_custom_assets'); function load_custom_assets($network_plugin) { if (strpos($network_plugin, 'example-plugin') !== false) { wp_enqueue_style('custom-css', 'path/to/your/custom.css'); wp_enqueue_script('custom-js', 'path/to/your/custom.js'); } }
Initialize custom functionality when a network plugin is loaded
Initialize custom functionality when a specific network plugin is loaded.
add_action('network_plugin_loaded', 'initialize_custom_functionality'); function initialize_custom_functionality($network_plugin) { if (strpos($network_plugin, 'example-plugin') !== false) { // your custom code to initialize functionality here } }