Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#28064 closed defect (bug) (fixed)

Can't sort list of Users by Name

Reported by: bobonwhidbey's profile bobonwhidbey Owned by: chriscct7's profile chriscct7
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.1
Component: Users Keywords: has-patch commit
Focuses: Cc:

Description

This bug has been around a long time, but it must be such a low priority that no one has addressed it. On the List of Users in the Dashboard, there are four columns labeled User, Name, E-Mail, and Role. The sort feature (both up and down) works for 3 of the columns, but not for the Name column. When clicking to sort on the Name column, it always sorts by User.

Attachments (1)

28064.patch (439 bytes) - added by rachelbaker 8 years ago.
Stops the Name column from appearing sortable

Download all attachments as: .zip

Change History (11)

#1 @jesin
10 years ago

  • Version changed from 3.9 to 3.1

I was able to reproduce this issue.

http://i.imgur.com/UanznGO.png

When users are sorted by the Name column the following arguments are passed to WP_User_Query.

$args = array(
	'number' => 20,
	'offset' => 0,
	'role' => '',
	'search' => '',
	'fields' => 'all_with_meta',
	'orderby' => 'name',
	'order' => desc
);

Here 'orderby' => 'name' is the same as username.

I have a patch that sets the orderby to meta_value and meta_key to first_name but if the First Name field is empty and the Last Name filled this bug appears again.

#2 @chriscct7
9 years ago

  • Keywords needs-testing added

Can't replicate

#3 @jesin
9 years ago

I'm able to replicate even on the latest trunk.

Create the following users

Username Name
abc ZZ
def AA
xyz XX

Now when you sort by the Name column it gets sorted by the username.

#4 @chriscct7
9 years ago

  • Owner set to chriscct7
  • Status changed from new to assigned

@rachelbaker
8 years ago

Stops the Name column from appearing sortable

#5 @rachelbaker
8 years ago

  • Keywords 2nd-opinion added

@jesin is correct about the cause of this bug, but I am not convinced we can sort Users in an expected manner when the single "Name" column is actually a combination of two optional values (first_name + last_name).

Instead I propose in 28064.patch we stop pretending that the "Name" column is sortable at all. I would like other opinions here.

#6 @rachelbaker
8 years ago

  • Keywords has-patch added; needs-testing removed

#7 @rachelbaker
8 years ago

  • Milestone changed from Awaiting Review to Future Release

#8 @boonebgorges
8 years ago

Wow, how annoying - I'd always assumed that this column showed display_name, but it is concatenating fn+ln. I don't think there's going to be a way to make this sorting work without doing some truly terrible things with usermeta joins, so +1 to 28064.patch

#9 @ocean90
8 years ago

  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Future Release to 4.6

#10 @rachelbaker
8 years ago

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

In 37314:

Users: Remove the “Name” column of the Users table from appearing sortable.

The “Name” column of the Users WP List Table is not sortable because this column displays a concatenation of two optional values, first_name and last_name. Even if WP_User_Query supported ordering queries in this manner, the resulting sequence would be chaotic.

Fixes #28064.

Props jesin, and rachelbaker.

Note: See TracTickets for help on using tickets.