Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#40168 closed defect (bug) (wontfix)

User roles should be populated in Alphabetical order

Reported by: subrataemfluence's profile subrataemfluence Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Users Keywords: has-patch has-screenshots
Focuses: administration Cc:


User role dropdown in user Add and Edit screens should be populated in alphabetical order by default.

Attachments (3)

40168.diff (487 bytes) - added by bor0 7 years ago.
Screenshot from 2017-03-16 18:40:59.png (172.7 KB) - added by subrataemfluence 7 years ago.
List sorted partially. Subscriber is still at the top of everything.
User Role Dropdown.png (19.0 KB) - added by lukecavanagh 7 years ago.
User Role Dropdown after patch

Download all attachments as: .zip

Change History (11)

7 years ago

#2 @bor0
7 years ago

  • Keywords has-patch added

#3 @subrataemfluence
7 years ago

  • Keywords reporter-feedback has-screenshots added

Just tried your patch but still it shows "Subscriber" on top of the list while it should come at the bottom of the list. Screenshot added.

#4 @subrataemfluence
7 years ago

  • Keywords reporter-feedback removed

7 years ago

List sorted partially. Subscriber is still at the top of everything.

#5 @bor0
7 years ago will take care of the issue that's putting the currently selected role on top.

Last edited 7 years ago by bor0 (previous) (diff)

#6 @lukecavanagh
7 years ago


The patch from @bor0 in ticket #40162

Fixes this issue.

7 years ago

User Role Dropdown after patch

#7 @desrosj
7 years ago

  • Keywords dev-feedback added

I'm not sure I agree with alphabetizing the roles in the dropdown. There is an implied hierarchy by the default roles in WordPress. Currently, all dropdowns order roles by least to most capabilities.

#40162 is a bug in that it gives priority to the role of the user being edited, but I think alphabetizing would lose that ordering, which is actually really consistent across all pages right now.

That being said, the patch fixes properly alphabetizes the list for me. I believe that it will only accurately alphabetize the list in English though. The translate_user_role() call in the foreach loop could potentially cause the list to be improperly ordered if the user's language is other than English because translation happens after your sort.

Marking this dev-feedback for another opinion.

#8 @johnbillion
7 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version changed from 4.7.3 to 2.1

I also don't think the list of roles should be displayed alphabetically. Plugins can control the way in which roles are displayed via various means, such as the wp_user_roles option, the $wp_roles->roles property, and the editable_roles filter.

Thanks for the suggestion, @subrataemfluence.

Note: See TracTickets for help on using tickets.