Is there a filter called 'network_admin_init'?

Is there a network equivalent to 'admin_init', or what do I have to do to add an action to network admin screens? I use 'admin_init' for an action on admin network screens, but the respective function is not executed. Thank you!

Edit: Here's what I want to do. The respective plugin writes custom database tables and should therefore only by activated on a per-site basis in a network.

function no_network_activation() {
    // echo 'test1 ';
    if ( is_network_admin()   isset($_GET['no-network-activation']) ) {
        // echo 'test2';
        add_action( 'network_admin_notices', 'no_network_activation_notice' );

        deactivate_plugins( plugin_basename( __FILE__ ) ); 

        if ( isset( $_GET['activate'] ) ) {
            unset( $_GET['activate'] );
        }
    }
}
add_action( 'admin_init', 'no_network_activation' );

function no_network_activation_notice(){
    // Echo an admin notice: no network activation possible
}

function myplugin_database_adder($networkwide) {
    // Redirect to network plugin url and add param to show the attempt of network-wide plugin activation
    if (is_multisite()  $networkwide) {
        header( 'Location: ' . network_admin_url( 'plugins.php?no-network-activation=true' ) );
        exit;
    }
    else {
        // Add the plugin database tables
        // [...] 
    }
}
register_activation_hook( __FILE__, 'myplugin_database_adder' );

Topic network-admin actions filters Wordpress

Category Web


You could restrict your admin_init callback with e.g. a is_network_admin() check.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.