I am trying to display user on query but i want to display order by user role. Suppose we have 2 user role, Gold and Free. I want to display Gold user first and then free users.
$args = array(
'order' => 'ASC',
'orderby' => 'display_name',
'role__not_in' => 'administrator',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'pin_code',
'value' => sanitize_text_field($_GET['pin_code']),
'compare' => 'LIKE'
),
array(
'key' => 'city',
'value' => sanitize_text_field($_GET['pin_code']),
'compare' => 'LIKE'
),
array(
'key' => 'county',
'value' => sanitize_text_field($_GET['pin_code']),
'compare' => 'LIKE'
),
)
);
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query($args);
i dont know how to achieve this in query arg.
__not_in
like the plague, they're incredibly slowposts_per_page
, are you showing only 10 users, or do you have pagination?gold
and thefree
roles explicitly, and remove therole__not_in
parameter. I also notice there is no pagination parameter in your query