Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter SaschaSchwartz

    (@saschaschwartz)

    Update: The bahaviour occurs when the plugin Better WP Security is active with the Option Hide > Hide Backend is enabled.

    Plugin Author David Sader

    (@dsader)

    “I need to prevent subscribers from entering the dashboard after login”

    In a network a user may in fact not belong to any blog at all. SO by default they will(should) always be able to see the “Global Dashboard” @ “/wp-admin/user/”. I won’t add code to my plugin to deny user’s ability to edit their profile.

    If a user only belongs to a sub site, they should get a WordPress error page that lists the sites they do have permission to login to.

    The default behaviour of WordPress is to redirect a login to the page the user requested to initiate the login. My plugin alone doesn’t change this behaviour.

    You can write and add your own plugin to /mu-plugins/ to redirect logins to wherever you like. Here’s an example of a snippet that works for me:

    <?php
    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) . 'wp-admin/';
               $primary_url = get_blogaddress_by_id($user_info->primary_blog);
               if ($primary_url) {
                    wp_redirect($primary_url);
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirect back to blog instead of dashboard in multisite’ is closed to new replies.