#20606 closed feature request (wontfix)
orderby rand param does not work with either WP_User_Query or get_users
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | Users | Keywords: | close |
Focuses: | Cc: |
Description
Using WordPress 3.2.1
$contributors = get_users(array('role' => 'contributor', 'orderby' => 'rand', 'number' => 3));
$wp_user_search = new WP_User_Query(array('role' => 'contributor', 'orderby' => 'rand', 'number' => 3)); $contributors = $wp_user_search->get_results();
Change History (5)
Note: See
TracTickets for help on using
tickets.
The
WP_User_Query::prepare_query()
method limits the fields you can order by. You can, however, edit the SQL ORDER BY clause directly by hookingpre_user_query
action.