Opened 10 years ago
Closed 8 years ago
#28064 closed defect (bug) (fixed)
Can't sort list of Users by Name
Reported by: | bobonwhidbey | Owned by: | 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)
Change History (11)
#3
@
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.
#5
@
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.
#8
@
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
@
8 years ago
- Keywords commit added; 2nd-opinion removed
- Milestone changed from Future Release to 4.6
+1 to 28064.patch.
I was able to reproduce this issue.
When users are sorted by the Name column the following arguments are passed to
WP_User_Query
.Here
'orderby' => 'name'
is the same asusername
.I have a patch that sets the
orderby
tometa_value
andmeta_key
tofirst_name
but if the First Name field is empty and the Last Name filled this bug appears again.