Wordpress Multisite Direct

Hi,

I would like to know how can I redirect my multisite users to their admin dashboard when they attempt to login to their site via the super admin login.

Currently when I attempt to login as a multisite user from the super admin website login it presents an error page saying

"You attempted to access the "wordpress" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "wordpress" dashboard, please contact your network administrator. If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way."

If it is possible I would like all my users to have the ability to login to their admin area using the super admin login page.

How can this be done?

Thanks!

  • Milan
    • WordPress Wizard

    Hello Gregwpmudev

    Hope you are well today and thanks for asking us. :slight_smile:

    Could you please try out this Snippet ?

    <?php
    function primary_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/themes';
                if ($primary_url) {
                    wp_redirect($primary_url);
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','primary_login_redirect', 100, 3);

    You can inject it on your site as mu-plugin or use it in your active theme's functions.php file, but I recommended to go with Mu-Plugins approach.

    To go by Mu Plugin approach, please follow these simple steps. :slight_smile:
    #1) Created directory named mu-plugins if it is not already exists in your wp-content directory.
    #2) Create file with .php extension in it. ( You can give it any name )
    #3) Finally Put above code in that file and save the file.

    Let me know how it goes then. :slight_smile:
    Cheers,
    Milan

  • Gregwpmudev
    • Flash Drive

    Hi Milan,

    Thank you for the reply.

    So do I add this snippet to my admin's functions.php file? If not, how would it work if it was inserted into my themes functions.php file? Isn't my theme and wordpress admin installed in a totally different directory?

  • Adam Czajczyk
    • Support Gorilla

    Hello Gregwpmudev!

    The snippet should work added to functions.php file of the current theme of the main site of your install. I'd however suggest going for MU (Must use) plugin as described at the end of Milan's post here:

    https://premium.wpmudev.org/forums/topic/wordpress-multisite-direct#post-1093429

    This way you avoid changing theme's file and also the code will stay in place and will work even if you switch or remove current theme from your site.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.