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: https://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' ); 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x