From 2002097f6f7fb01e250990a6ecb86f335cf0660b Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Fri, 13 Feb 2015 06:29:57 +0000 Subject: [PATCH] Create the My Sites URL in the context of a user's primary site. Switch to the user's primary (or active) site before creating the My Sites URL. This previously linked to the current site's dashboard, even if a user was not a member of that site. Props simonwheatley for the initial patch. Fixes #31314. git-svn-id: https://develop.svn.wordpress.org/trunk@31445 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/admin-bar.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 9e75de5d13..b4be9379af 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -333,11 +333,13 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) return; + switch_to_blog( $wp_admin_bar->user->active_blog->blog_id ); $wp_admin_bar->add_menu( array( 'id' => 'my-sites', 'title' => __( 'My Sites' ), 'href' => admin_url( 'my-sites.php' ), ) ); + restore_current_blog(); if ( is_super_admin() ) { $wp_admin_bar->add_group( array(