Make WordPress Core

Opened 13 years ago

Last modified 4 years ago

#17394 reopened defect (bug)

Network Admin -> Sites -> Users not report correctly

Reported by: whiteatom's profile whiteatom Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1.2
Component: Users Keywords: needs-testing needs-patch
Focuses: administration, multisite Cc:


The Network Admin -> Sites -> Users screen does not list all users in the site. I see the symptom of this issue has been reported before, but I have found the cause (in my case anyway).

Example Scenario:
In my set up I have added plugins that add user roles: a registration plugin that adds "Registration Admin" and a event management plugin that adds "Office" and "Committee". I have the registration plugin installed in all sites (root and test), but the event plugin in only installed in the test site.

When I add a user to the root site, I can choose the normal roles or "Registration Admin", when I add a user to the test site I can choose the normal roles or any of the 3 new roles that have been added.

When I view the list of users on the Network Admin, not all users are displayed in the list. It appears the Network Admin screen works in the context of the root site, where the event plugin is not installed. As a result, the Office and Committee roles are not available in the root site, and users of the sub-site with the those roles do not show in the user list.

The filters show the correct total number of users beside All, but the additional roles unique to the sub-site are not listed. In the sub-site Dashboard, they show correctly, and if I install the other plugin to add the Office and Committee roles to the root site they will show in the Network Admin -> Sites -> Users screen for the sub-site.

It would appear the user list for a sub-site will ignore users that are assigned a role that doesn't exist in the root site, even though they are assigned a valid role in the site displayed.

This bug is reproducible by adding roles to sub-sites.

I would a happily help with more clarification or resolving this issue as needed. I know it's not critical, but it is very frustrating when administering a large multi-site network.

Attachments (2)

test-role.php (460 bytes) - added by whiteatom 13 years ago.
Plugin to add test role
17394.diff (845 bytes) - added by scribu 13 years ago.

Download all attachments as: .zip

Change History (18)

#1 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

The query looks like this:

FROM wp_users
INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id )
WHERE 1 =1
AND (wp_usermeta.meta_key = 'wp_3_capabilities')

As you can see, roles have nothing to do with it.

Instead, the events plugin probably isn't using the capabilities system at all. Nothing WP core can do about that.

#2 @whiteatom
13 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Well the roles have to come in somewhere because the filters are at the top of the list, and they are displayed in the list it's self. When i add a user to the sub-site with a role that is only in the sub-sute, but not in the root, the user doesn't show up in the users list in the network admin.

I have written a plugin that JUST adds the role and I can reproduce this issue.

$editor = get_role('editor');
$ed_caps = $editor->capabilities;
add_role('testRole', 'Test', $ed_caps);

If I activate this plugin in the subsite, and assign a user the 'Test' role in the sub-site Dashboard, all is well. When I go to view the users from the Network Admin, that user is not displayed in the list. If I add the plugin to the root site, they appear with the role 'Test', and 'Test' role is displayed in the role filters above the user list.

I'd love to say it's unrelated to the core, but it has to be.

#3 @scribu
13 years ago

Works for me, even if I remove those 3 lines of code afterwards.

Also, see if the same happens when going to Site Without Events Plugin Activated -> WP Admin -> Users.

#4 @scribu
13 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

Wait, just because you assign a user the "Registration Admin" role to the root site, doesn't mean that he will show up on all the rest of the sites.

So, there's actually no bug at all. You just didn't assign any role to that particular user on that particular site.

#5 @scribu
13 years ago

If you're still confused, say so, but please don't re-open this ticket.

13 years ago

Plugin to add test role

#6 @whiteatom
13 years ago

I'm not confused.. but 'm quite sure you're not quite getting what I mean. I don't mean to be insulting, but I can reproduce this problem over and over.. I promise you it is a real bug. Forget the Registration Admin and Office Roles.. just look at my example plugin that just adds the test role - the full plugin is attached so you can try it out.

Follow this process and you can see the issue I am referring to.

  1. Add this plugin to your plugins folder, create a new subsite, go to the dashboard and activate the plugin in the new subsite.
  2. Now, go back to the network admin, go to Sites and Edit your new site.
  3. Click on Users and add an existing user (or a new user) to this new subsite with the role Test.
  4. It says 'User Added', but they don't show up in the list. The All(#) shows the extra user, but you cannot see them in the list.
  5. If you go back to the Sites page, you can see the user name listed beside your subsite.
  6. If you go to the Dashboard for the subsite, you can see the user and the role.

Now, the move that convinced me that this is an issue with the Network Admin running in the context of the root site.

  1. Go to the dashboard of your root site, and activate the plugin.
  2. Now go back to the network admin and Edit the subsite, and the user will magically appear.

The bug seems to be that the network admin only looks at it's own environment when showing the users list for subsites. For roles that exist in the subsite, but not the root site, the users are not displayed - I believe this to be the bug.

For me, I am running a multisite environment that does event management, so the root site isn't even used, only the event specific subsites are used. I have heavily extended wordpress with a variety of roles based on the needs of each event - several of these conflicting with roles used in a different event. In each dashboard, this is fine, but in the Network Admin users are missing. Because of the conflicts, I cannot install all the event plugins into one site ( my root site), so I have had to write a custom plugin that adds each unique role to the root site, just so I can see the users in the list on the Network Admin.

I assure you this is a bug. I understand that you probably get lots of people who don't understand how to use this package correctly and call every mistake they make a bug. I hope that after running through this example with this simple plugin, you will see what I am referring to and reopen this ticket yourself. If you cannot see the problem I'm referring to, please comment and I will do a screen capture to demo it.


#7 @scribu
13 years ago

  • Keywords needs-patch added
  • Milestone set to Future Release
  • Resolution invalid deleted
  • Status changed from closed to reopened

Indeed, it's a very sneaky bug. Thanks for the detailed steps to reproduce. Should have asked for them from the beginning.

13 years ago

#8 @scribu
13 years ago

  • Keywords has-patch added; needs-patch removed

The problem stems from the fact that roles are stored exactly as individual capabilities.

So, if a role isn't registered, it won't appear in $user_object->roles.

Due to this same ambiguity, the patch is also fragile.

Related: #10201

#9 @whiteatom
13 years ago

I don't know the core that well, but I would assume the role registration is dependant on the site specific global variables as this problem goes away in the subsite dashboard. Would is be possible to load the sub-site globals when viewing wp-admin/network/site-info.php?

Just a thought.

Thanks for the amazing response time.

#10 @hidgw
12 years ago

  • Cc hidgw added

#12 @jeremyfelt
10 years ago

  • Component changed from Network Admin to Users
  • Focuses administration added

#13 @chriscct7
9 years ago

  • Keywords needs-testing needs-refresh added

#14 @jeremyfelt
9 years ago

#19765 was marked as a duplicate.

#15 @jeremyfelt
9 years ago

  • Keywords needs-patch added; has-patch needs-refresh removed

It's worth looking at the conversation in #19765 (and patch) in the context of this ticket.

#16 @desrosj
4 years ago

  • Milestone set to Future Release

This still needs a patch to be considered.

Note: See TracTickets for help on using tickets.