Make WordPress Core

Opened 12 years ago

Closed 9 years ago

Last modified 8 years ago

#22993 closed defect (bug) (fixed)

Admin - users without a role are difficult to find

Reported by: logikal16's profile logikal16 Owned by: johnbillion's profile johnbillion
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.5
Component: Users Keywords: has-patch has-unit-tests has-screenshots
Focuses: ui, administration Cc:

Description

There doesn't appear to be a filter to display users *without* a role (see the screenshot). The ideal solution would be to add a filter for "None".

http://i.imgur.com/3S5pH.png

Attachments (5)

22993.diff (3.0 KB) - added by spmlucas 11 years ago.
22993.2.diff (2.6 KB) - added by spmlucas 11 years ago.
22993.3.diff (3.4 KB) - added by johnbillion 9 years ago.
22993.4.diff (9.9 KB) - added by johnbillion 9 years ago.
Screen Shot 2015-10-08 at 21.29.14.png (86.0 KB) - added by johnbillion 9 years ago.

Download all attachments as: .zip

Change History (22)

#1 @MikeHansenMe
12 years ago

  • Cc mdhansen@… added
  • Keywords close added

I think the only way you could get a user without a role would be through a plugin. I would think these plugins should create a role(without capabilities if necessary) if they do not wish to use one of the existing roles. Then their custom role would be able to be filtered.

Last edited 12 years ago by MikeHansenMe (previous) (diff)

#2 follow-up: @markoheijnen
12 years ago

  • Keywords ux-feedback added; dev-feedback close removed

Thats incorrect. You can do it through the interface of WordPress but I'm curious if we should check on it.

#3 @logikal16
12 years ago

WP core allows for users without roles, hence this should be core territory. On sites with thousands of users, the ability to find users without roles is important.

IMO, there's no reason why a role filter couldn't get added, and live beside the existing text filters, e.g.

Administrator (440) | Subscriber (50) | No Role (25)

Patch coming soon...

#4 in reply to: ↑ 2 ; follow-up: @MikeHansenMe
12 years ago

Replying to markoheijnen:

Thats incorrect. You can do it through the interface of WordPress but I'm curious if we should check on it.

Where are you able to add a user without a role? I attempted to manually add a user via Users -> Add New and it makes you select a role.

For allowing anyone to register. The option on Settings -> General makes you select a default role.

I am just curious because I am unaware of it.

#5 in reply to: ↑ 4 ; follow-up: @helen
12 years ago

Replying to MikeHansenMe:

Where are you able to add a user without a role?

Not add, but you can set "No role for this site" from their profile.

#6 in reply to: ↑ 5 @MikeHansenMe
12 years ago

Replying to helen:

Replying to MikeHansenMe:

Where are you able to add a user without a role?

Not add, but you can set "No role for this site" from their profile.

Thanks, I was unaware of this. I am all for adding a link to filter users without roles then.

#7 @logikal16
12 years ago

The first issue is within count_users(). By default, it uses a LIKE query to see if the current role is within the serialized wp_capabilities array. For users without roles, this won't work.

  • A subscriber: a:1:{s:10:"subscriber";b:1;}
  • A user with no role: a:0:{}

#8 follow-up: @markoheijnen
12 years ago

Thats shouldn't be a problem since the value is always the same so we can check on the value "a:0:{}"

#9 in reply to: ↑ 8 @nacin
12 years ago

Replying to markoheijnen:

Thats shouldn't be a problem since the value is always the same so we can check on the value "a:0:{}"

Unless the user has a single capability (no role).

@spmlucas
11 years ago

#10 @spmlucas
11 years ago

  • Keywords has-patch added; needs-patch removed

I'm new to core and this is my first patch attempt, so please be merciless in your criticism, both of the patch itself the ticket update.

I left count_users() alone but I suppose it could also be easily updated to include a count for users with no role if that's deemed necessary. Went with a NOT REGEXP to find users with no role, even if they have other capabilities defined. Have not tested in multisite, but have no reason to believe it won't work there.

Version 0, edited 11 years ago by spmlucas (next)

@spmlucas
11 years ago

#11 @chriscct7
9 years ago

  • Focuses ui administration added
  • Keywords needs-refresh added; has-patch removed

@johnbillion
9 years ago

#12 @johnbillion
9 years ago

  • Keywords has-patch needs-unit-tests added; ux-feedback needs-refresh removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to johnbillion
  • Status changed from new to assigned

22993.3.diff addresses this and is based on the patch from spmlucas.

The main difference is that it modifies the count_users() function so it also counts the number of users with no role. This means that no extra database queries are added to the Users screen by default, and the potentially expensive wp_get_norole_users() function is only called when the user clicks the 'No role' filter.

This needs unit tests for wp_get_norole_users() and count_users(), and some comprehensive testing on multisite. Also the wp_get_norole_users() function needs a better name.

@johnbillion
9 years ago

#13 @johnbillion
9 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#14 @johnbillion
9 years ago

In 22993.4.diff:

  • wp_get_norole_users() is now wp_get_users_with_no_role().
  • Tests for count_users() and wp_get_users_with_no_role() on single site and multisite.

I'm very happy with this patch. No additional queries are added to the Users screen, unless you click the 'No role' link on a site which has some users without a role. Multisite remains unaffected and doesn't show the 'No role' link anywhere.

#15 @johnbillion
9 years ago

  • Keywords has-screenshots added

#16 @johnbillion
9 years ago

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

In 34965:

Introduce the ability to filter the Users admin listing screen by users with no role, if such users exist.

Fixes #22993
Props spmlucas, johnbillion

This ticket was mentioned in Slack in #core-multisite by helen. View the logs.


8 years ago

Note: See TracTickets for help on using tickets.