Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#17179 closed enhancement (duplicate)

Sort user by metadata value

Reported by: ziofix Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.1
Component: Users Keywords: has-patch
Focuses: Cc:


It would be nice to sort users by metadata value, the way it works for posts. For instance:

$users = get_users(array(
  'orderby'  => 'meta_value_num', 
  'order'    => 'DESC', 
  'meta_key' => 'score', 

Therefore it needs to add the lines below at line 436 of file wp-includes/user.php:

} elseif( (!empty($qv['meta_key'])) && ( 'meta_value' == $qv['orderby']) ) {
  $orderby = "$wpdb->usermeta.meta_value";
} elseif( (!empty($qv['meta_key'])) && ( 'meta_value_num' == $qv['orderby']) ) {
  $orderby = "$wpdb->usermeta.meta_value+0";

Attachments (1)

17179.patch (714 bytes) - added by SergeyBiryukov 4 years ago.
Actual patch

Download all attachments as: .zip

Change History (4)

@SergeyBiryukov4 years ago

Actual patch

comment:1 @c3mdigital2 years ago

  • Keywords needs-refresh added

comment:2 @c3mdigital2 years ago

  • Keywords needs-refresh removed
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #21581.

comment:3 @SergeyBiryukov2 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.