#17179 closed enhancement (duplicate)
Sort user by metadata value
| Reported by: | ziofix | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Users | Version: | 3.1 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
Description
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)
Change History (4)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Actual patch