Put My Sites navigation from admin Toolbar in regular menu


I have multiple branches and 1 central site.
The entire multisite install is private for only logged in users.
When logged in I want all users to access the central site but branch access is restricted.

1. Do I need a membership plugin to control access? Would you suggest S2Members, Membership by Justin Tadlock or another plugin for a multisite?

2. I have added a menu for the central site. When users are on the central site I want a menu item My Branch that links them to the branch/branches that they are authorized to view. I will hide the toolbar on the front-end. So I want to add the My Sites (only I'll call it My Branches) from the WordPress toolbar to a standard menu. How can I do this?

Thanks for your support

~ Ruth

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hello, Ruth! How are you today?

    1. Yes, a member management plugin is going to be the simplest solution for this. I'm most familiar with our Membership plugin, which can be used as a part of your network, with a little tweaking. We've got a manual, setting up for multisite is on page 61.

    2. I wish this was built in, but the best solution I can find is to do a little code to add the function to list a users blogs, here: https://wordpress.org/support/topic/list-which-sites-a-multisite-user-belongs-to. That thread is a little old, and it won't take you all the way to what you want to do, but it's a good start.

    Thanks for your questions!

  • Ruth Maude
    • New Recruit

    I'm almost there!

    I have the main site menu in the top right corner of theme for all sites except for the main site.
    On the main site I have the main menu in another position and in the top right corner I now have it saying Return to Branch: and the link to the branch.

    My only issue now is that those who have access to multiple sites get a huge ugly list or all branches at the top right.

    Is there a way to make this a conditional drop down menu?

    If they have access to only one site "Return to Branch: Toronto"
    If they have access to more sites it becomes a drop down list of "My Branches"

    <?php //store the current blog_id being viewed
    global $blog_id;
    $current_blog_id = $blog_id;
    if ($blog_id == 1) {
      //swap the top menu with the sub header menu for blog id of 1
    	if( has_nav_menu( 'sub-header-menu', 'responsive' ) ) {
    				wp_nav_menu( array(
    					 'container' => '',
    					 'fallback_cb' => false,
    					 'menu_class' => 'top-menu',
    					 'theme_location' => 'sub-header-menu'
    				) );
    	/* add link to home branch */
    		if(is_user_logged_in()) {
    		global $current_user;
    		  $blogs = get_blogs_of_user( $current_user->id );
    			 if($blogs) {
    				 foreach ( $blogs as $blog ) {
    				 echo '<ul class="top-menu"><li class="sub-menu">Return to Branch: <a href="http://' . $blog->domain . $blog->path .'">' .  $blog->blogname . '</a></li></ul>'; }
    } else {
        while ($blog_id != 1)
    //switch to the main blog which will have an id of 1
    //output the top menu from blog id of 1
    if( has_nav_menu( 'top-menu', 'responsive' ) ) {
     wp_nav_menu( array(
     'container' => '',
     'fallback_cb' => false,
     'menu_class' => 'top-menu',
     'theme_location' => 'top-menu'
     ) );
    //switch back to the current blog being viewed

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.