Redirect all users, except network administrators, from the main site to a subsite

You’ll need to tie into template_redirect hook where you will check the site and the user and then redirect if needed.

function redirect_to_subsite() {
    if( is_main_site() && !current_user_can('manage_network') ) {
        $blog_id = 5; // <<----- Update the ID to the subsite blog ID you want to redirect to
         wp_redirect( get_site_url( $blog_id ) );
         exit();
     }
 }
 add_action( 'template_redirect', 'redirect_to_subsite' );

Leave a Comment