Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#19765 new defect (bug)

site-users.php in network admin doesn't display users with custom roles

Reported by: wpdavis Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: administration, multisite Cc:


In the network admin when looking at the users of a specific site, if the site has a custom role the users with that role will not show up. The patch attached ensures that switch_to_blog() is used at the correct places so that data is being gathered from the correct site, not from the main site.

Attachments (3)

class-wp-users-list-table.patch (1.7 KB) - added by wpdavis 2 years ago.
class-wp-users-list-table.diff (1.6 KB) - added by wpdavis 2 years ago.
Removing extra switch_to_blog
19765.patch (2.8 KB) - added by wpdavis 6 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 nacin2 years ago

I would think that a switch_to_blog() is unnecessary here. We know the user's roles from the meta key, or at least the role's key ("administrator" rather than "Administrator"). We should be able to display the role's key in the case where the role is not registered on the main site.

Perhaps we should have a switch_to_blog() for larger reasons. PeteMall?

comment:2 DrewAPicture2 years ago

  • Cc xoodrew@… added

comment:3 wpdavis2 years ago

Which switch_to_blog are you referring to? The one I added in prepare_items is necessary for the query for custom roles to run correctly — without it, when you look for all users with custom_role it returns nothing.

wpdavis2 years ago

Removing extra switch_to_blog

comment:4 wpdavis6 months ago

Problem is still relevant. You need to switch_to_blog() in order to get the roles at all — even the slugs — but you can combine everything switch_to_blog() is needed for in one place. Patch attached.

wpdavis6 months ago

comment:5 jeremyfelt3 months ago

  • Component changed from Network Admin to Users
  • Focuses administration added
Note: See TracTickets for help on using tickets.