Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17829 closed defect (bug) (fixed)

Site Admin goes to User Admin if user has no sites

Reported by: trepmal's profile trepmal Owned by: nacin's profile nacin
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Network Admin Keywords: has-patch commit
Focuses: multisite Cc:

Description

If a Super Admin is not specifically added as a user to any site, the Site Admin link in the Howdy dropdown goes to the User Admin.

http://cl.ly/7goN/site-admin-user-admin.png

It looks like this has been happening since 3.1.

the patch adds a check to see if the current user has any sites. If the user doesn't have any sites, the link's title and text are changed to User Admin.

Attachments (7)

admin-header.diff (1.2 KB) - added by trepmal 13 years ago.
admin-header.2.diff (1.1 KB) - added by trepmal 13 years ago.
less repetition - but I'm sure someone can make it even better
admin-header.3.diff (1.1 KB) - added by trepmal 13 years ago.
even better - hopefully :)
admin-header.4.diff (1.1 KB) - added by trepmal 13 years ago.
removed my stray exclamation mark
admin-header.5.diff (1.3 KB) - added by trepmal 13 years ago.
a little bit of cleanup - brackets and indentation
17829.diff (1.3 KB) - added by ryan 13 years ago.
17829.2.diff (1.5 KB) - added by nacin 13 years ago.

Download all attachments as: .zip

Change History (15)

#1 @scribu
13 years ago

  • Component changed from General to Network Admin
  • Milestone changed from Awaiting Review to 3.2
  • Version changed from 3.2 to 3.1

Moving to 3.2 milestone for consideration.

Code could be made less repetitive.

@trepmal
13 years ago

less repetition - but I'm sure someone can make it even better

#2 @nacin
13 years ago

  • Owner set to nacin
  • Status changed from new to accepted

A note, I think we call it Global Dashboard, rather than User Admin, but I'd have to check.

To improve the patch, try setting $label to your translated string. Then just build the link with the variable, escaping in the attribute with esc_attr.

@trepmal
13 years ago

even better - hopefully :)

@trepmal
13 years ago

removed my stray exclamation mark

#3 @nacin
13 years ago

  • Keywords commit added

We need a better function than get_blogs_of_user() that provides us boolean values as to whether someone has a blog. Without object caching that function really stinks cause it runs a lot of cross-blog queries.

Regardless, that patch looks good for 3.2. Would rather it be prettied a little -- if were are to do else { } when we also need to do brackets around the first if statement.

Likewise $links[10] needs an extra indent and the empty lines after the else and before the $links[10] assignment aren't really needed.

@trepmal
13 years ago

a little bit of cleanup - brackets and indentation

@ryan
13 years ago

#4 @ryan
13 years ago

Another approach is to fix get_dashboard_url(). wp-login.php also needs a tweak to deal with this scenario.

#5 @nacin
13 years ago

I think fixing get_dashboard_url() may be a better approach. I was wondering why we might want to send super admins to the user admin. Answer to me seems never.

@nacin
13 years ago

#6 @nacin
13 years ago

First patch solved the login, but not the link in the admin header. get_dashboard_url() would return wp-admin/user for supes, and I think we can agree that if the supes have no blogs, it should go to the main site (admin_url()).

Second patch handles this by properly forcing the code to skip one branch and end up in the else.

#7 @ryan
13 years ago

Works for me.

#8 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [18328]:

Fix handing of super admins that don't have a blog in get_dashboard_url() and login. Props nacin. fixes #17829

Note: See TracTickets for help on using tickets.