Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#40162 closed enhancement (fixed)

Don't alter the order of roles in the Role dropdown when editing a user

Reported by: johnbillion Owned by: johnbillion
Priority: normal Milestone: 4.8
Component: Users Version:
Severity: normal Keywords: has-screenshots has-patch commit
Cc: Focuses: administration

Description

When editing a user, the user's current role gets moved to the top of the list of roles shown in the Role dropdown. Reordering items in a list can be confusing, and although the roles in WordPress aren't strictly hierarchical there is an implied hierarchy that should be maintained in this list.

Attachments (5)

editor.png​ (30.8 KB ) - added by johnbillion 10 years ago.
contributor.png​ (30.4 KB ) - added by johnbillion 10 years ago.
40162.diff​ (1.1 KB ) - added by bor0 10 years ago.
customer.png​ (17.1 KB ) - added by bor0 10 years ago.
User Role Dropdown.png​ (19.0 KB ) - added by lukecavanagh 10 years ago.
User Role Dropdown after patch

Download all attachments as: .zip

Change History (16)

#1 @johnbillion
10 years ago

  • Keywords has-screenshots added
  • Type defect (bug) → enhancement

#2 @johnbillion
10 years ago

  • Keywords good-first-bug added

#3 @ketuchetan
10 years ago

Hi @johnbillion

So, you mean we need to display the all the roles list default way, not the user's current role gets moved to the top of the list?

If I understand properly then please let me know so I can add my patch here.

#4 @swissspidy
10 years ago

@ketuchetan That's how I understand it, yes.

#5 @lukecavanagh
10 years ago

Seems like that is defined here.
​https://github.com/WordPress/WordPress/blob/master/wp-admin/user-edit.php#L363

Using this function.
​https://developer.wordpress.org/reference/functions/wp_dropdown_roles/

So default user roles in core hierarchy would be the following then?

​https://codex.wordpress.org/Roles_and_Capabilities#Summary_of_Roles

Super Admin
Administrator
Editor
Author
Contributor
Subscriber

How would additional user roles either custom added or by a plugin relate to the hierarchy of the user roles in core, would those be based on user capabilities, for example WooCommerce adds in two new user roles, Customer and Shop Manager.

​https://codex.wordpress.org/Roles_and_Capabilities#Capabilities

Last edited 10 years ago by lukecavanagh (previous) (diff)

#6 @bor0
10 years ago

  • Keywords has-patch added; needs-patch removed

How would additional user roles either custom added or by a plugin relate to the hierarchy of the user roles in core, would those be based on user capabilities, for example WooCommerce adds in two new user roles, Customer and Shop Manager.

While related, I think this is out of scope for this ticket as this is only about not resetting the index of the currently selected role.

After proposed patch (40162.diff) here's how it appears like:

@lukecavanagh
10 years ago

User Role Dropdown after patch

#7 @lukecavanagh
10 years ago

  • Version → 4.7.3

@bor0

The patch applies cleanly and works well.

#8 @bor0
10 years ago

Thank you @lukecavanagh. Please take a look at #40168 also.

#9 @johnbillion
10 years ago

  • Keywords commit added; ux-feedback good-first-bug removed
  • Milestone Awaiting Review → 4.8
  • Version 4.7.3

#10 @johnbillion
10 years ago

  • Owner set to johnbillion
  • Status new → accepted

#11 @johnbillion
10 years ago

  • Resolution → fixed
  • Status accepted → closed

In 40323:

Users: Don't push the current user's role to the top of the list in wp_dropdown_roles().

This brings consistency to the order in which roles are displayed in the Roles dropdown when editing users.

Props bor0

Fixes #40162

Note: See TracTickets for help on using tickets.