Can't access site dashboard through main blog, pro sites issue?

I have a multi site network, I'm running pro sites and domain mapping amongst other WPMU DEV plugins. I love the new work done to Pro sites, however, I've noticed when my users login to their account through the main blog, then click on "admin dashboard" to visit their dashboard, they get the following error:

"You attempted to access the "SITE NAME" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "SITE NAME" 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."

Is there a way to enable it so that my users can access their dashboard, but by logging into their account on the main blog?

here's a link to a screencast I made showing the issue:
http://www.skizzar.com/screencast/skizzar-login-issue.mp4

  • Tyler Postle
    • CGO

    Hey Samuel,

    Hope you're doing well today!

    Yes, that's default multisite behaviour; however, you can try this code to redirect a user to their primary blog after logging in:

    <?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) . '';
                if ($primary_url) {
                    wp_redirect($primary_url);
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);

    I've made it into an mu-plugin for you so you can just drop it into your /wp-content/mu-plugins folder. Unzip the attached folder and upload the redirect-primary-blog.php file to your mu-plugins folder, if your mu-plugins folder doesn't exist inside wp-content then just create it :slight_smile:

    Hope that helps and let us know if you have any further questions.

    All the best,
    Tyler

  • Anang
    • New Recruit

    Hi Samuel

    Working with Tyler here :slight_smile:

    Can you confirm that the path of the file is /wp-content/mu-plugins/redirect-primary-blog.php and you need upload it using FTP, not add new plugins on dashboard.

    If the path is correct, could you enable wordpress debug ? Edit your wp-config.php and find this line :
    define('WP_DEBUG', false);
    change it to :
    define('WP_DEBUG', true);

    Let me know the result :slight_smile:

    Best Regards

    • Samuel
      • The Incredible Code Injector

      Hi @Anang, Firstly, I can confirm I have uploaded the file to mu-plugins directory via FTP. So I do get a few errors when I run wordpress in debug mode, a couple related to a plugin called Kirki, and then the following that relate to my theme:

      [11-Jul-2015 10:08:22 UTC] PHP Notice: Undefined variable: page_data in /home/samskirrow/public_html/wp-content/plugins/foresound-customizations/skizzar-slider.php on line 48
      [11-Jul-2015 10:08:22 UTC] PHP Notice: Trying to get property of non-object in /home/samskirrow/public_html/wp-content/plugins/foresound-customizations/skizzar-slider.php on line 48

      I can't see that any of these would be the reason for it not working.

      Update on the functionality though, it seems now that when a user logs in, they are redirected to their site, instead of to their account area, and then to their dashboard - here is a link to my screencast showing the issue.
      http://www.skizzar.com/screencast/skizzar-login-issue-2.mp4

  • Anang
    • New Recruit

    Hi @Samuel

    I'm agree that errors is not related.. And as redirect is working now, you can turn off the WP_DEBUG now.

    You can change the code to this code below, to redirect your user to their dashboard :

    <?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) . '';
                if ($primary_url) {
                    wp_redirect($primary_url.'/wp-admin');
                    die();
                }
            }
        }
        return $redirect_to;
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);

    Let me know the result :slight_smile:

    Best Regards

  • Anang
    • New Recruit

    Hi Samuel

    Assuming your account url is : http://www.skizzar.com/your-account/
    Change the code above with :

    <?php
    function ds_login_redirect( $redirect_to, $request_redirect_to, $user )
    {
                    wp_redirect(home_url('/your-account'));
                    die();
    }
    add_filter('login_redirect','ds_login_redirect', 100, 3);

    .

    ..I think this should be a feature of ProSites by the way, is there anywhere I can put in a feature request?

    Yeah, I'm agree it should be a feature. You could post the suggestion here :
    https://premium.wpmudev.org/forums/forum/feature-suggestions

    Let me know the result :slight_smile:

    Best Regards

  • Anang
    • New Recruit

    Hi Sam

    FYI ,I create a testing user : wpmudevtest to one of your sub site, to check admin menu on your-account page. I hope that's okay :slight_smile: Because I can't see the menu if I'm login as super admin.

    May I know what plugin do you use to create that menu ? How I can find the settings in Dashboard ?

    Let me know more :slight_smile:

    Best Regards

    • Samuel
      • The Incredible Code Injector

      Hi, Yep it's a admin theme plugin called Clientside - you can change the menu settings by going to Tools > Admin Menu Editor on the blog that you wish to edit the menu on. Though you should be able to see everything when logged in as super admin.
      Sam

  • Anang
    • New Recruit

    Hi @Samuel

    I have check again, and it's not in Admin Menu Editor. We can't manage that menus, because it's default from your themes plugin. And I realize that, there's 2 Dashboard links on that menu. One is to Network Dashboard and The other is to Subsite Dashboard.

    So how about to hide Network Dashboard when the user have no roles in Network Dashboard, and keep the other Subsite Dashboard to allow user go to their own Dashbaord.

    Let me know what do you think ?

    Best Regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.