How To Login Redirect WordPress Users To Their Subsite?

You can automatically redirect users to their respective sub-site after login in your WordPress multisite network. This can easily be done either by adding some code in your theme’s function.php file or via Code Snippets plugin.

function ds_login_redirect( $redirect_to, $request_redirect_to, $user )
    if ($user->ID != 0) {
        $user_info = get_userdata($user->ID);
        if ($user_info->primary_blog) {
            $primary_url = get_blogaddress_by_id($user_info->primary_blog) . '/' ;
            if ($primary_url) {
    return $redirect_to;
add_filter('login_redirect','ds_login_redirect', 100, 3);

Given code will automatically redirect your WordPress multisite users to their respective sub-sites as soon they login from main or any other website on your network.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.