WordPress Snippets at WPcustoms

Block access to the mainsite dashboard in WordPress multisite

if you are running a WordPress Multisite and want to restrict the access to the dashboard of the main site to everyone apart from the super admin use this snippet


/**
 * Snippet Name: Block access to the mainsite dashboard in WordPress multisite
 * Snippet URL: http://www.wpcustoms.net/snippets/block-access-to-the-mainsite-dashboard-in-wordpress-multisite/
 */
 function wpc_wpadmin_blockusers() {
    if ( !current_user_can( 'manage_network' ) ) {
    wp_redirect( home_url() );
    exit;
}
add_action( 'admin_init', 'wpc_wpadmin_blockusers' );