Taking @Kaperto’s advice, I did the following which works:
$user_query = new WP_User_Query( array(
'role__in' => ['role1','role2''],
'orderby' => 'meta_value_num',
'order' => 'ASC',
) );
$users = $user_query->get_results();
Related Posts:
- SQL query equivalent to WP User Query
- WP User Query get all authors with last name starting with specific letter
- Sort users by “birthday” using WP_User_Query
- Slow WP_Query for custom post type
- Hide Administrators From User List except current user (administrator)
- How to display user order by role
- Order by summing multiple values
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- SQL query injection with fifu image
- WP Query – grouping posts by same meta key, adding together values from another key
- Set “editor” role to existing user
- Get users query makes the site loading time too big?
- WP_Query with “post_title LIKE ‘something%'”?
- Pagination with custom SQL query
- Use REGEXP in WP_Query meta_query key
- Order by DESC, ASC in custom WP_Query
- Is it possible to wrap Geo Location search around WP_Query?
- Getting wrong relationship value in $args in wp_Query?
- Getting all user metadata from user
- Is it possible to select against a post’s parent’s fields with WP_Query?
- How to make an activities stream mixing posts and comments?
- Return ID of authors who have at least one post
- SQL Statement generated by WP_Query not producing expected results
- What is an efficient way to query based on post_meta?
- What’s wrong with this WP query?
- Group posts by meta_key
- Recommended way to drop a pending query (in pre_get_posts)?
- how to retrieve specific product attribute value in an sql query?
- Would this post meta be better added to the post table rather than post_meta table
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- How to hide post content/meta from everyone except the post author and admin
- Filter user list that meta_value is empty
- Query wp_usermeta alongside wp_users
- Advanced WP Query hogs the SQL server
- WordPress Query is taking more then 20 second and stuck on creating index
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Mysql query LIKE not working
- Select from wp_post and multiple meta_value from wp_postmeta
- Order by custom table and multiplication
- How to correctly pass values to wpdb->prepare()?
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to order posts in wp_query by the user role (2 roles in array)
- How to use MySQL’s MATCH AGAINST in WP_Query?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Complex WP SQL Query
- Add “Category” to Mysql Query
- Mysql query and order meta value
- Help with WP_Query – Too many mySQL queries
- Using hook to use DISTINCT in a wp_query
- Sorting events by descending date, and ascending time if multiple events on a date
- pagination with ‘no_found_rows’ => true,
- Import wp users via one click demo option
- How to verify wp user password by sql query in wp? [closed]
- Dynamic User Id
- Wp query show post by author name or post title or post content
- Why does get_posts only show results for Admins or logged-out users?
- wordpress ajax relationship query
- WordPress SQL Issue not returning correct reselts
- Debugging wp_query orderby for taxonomy
- How can I prevent certain custom roles from seeing other custom roles on the user list page?
- Meta Query doesn’t works as espected
- Get multiple users with meta value in one query and populate WP_User class
- Display if author page is author page of current user
- Get user first name from custom endpoint
- Query where ANDing slug values not working
- Show menus to one admin username
- WP_Query: apply an SQL function to meta fileld value
- Link Author URL’s based on a custom field
- How to avoid filling up an array each time I run a WP_query?
- How to SQL query posts IDs by categories AND authors?
- Randomly select one of last 3 posts
- Query multiple meta key values for template
- Passing a SQL query to the WP Query
- WP_Query() not working as expected
- Query posts by post type, author and post meta
- Random users always showing same 8 users
- Any way to use FETCH_KEY_PAIR with $wpdb?
- What is the equivalent WP_Query of a SQL Query?
- INNER JOIN custom tables – SQL Query
- use mysql variable in a $wpdb->query to reindex a column?
- One of two similar WP Query is very slow
- Fix wp_term_relationships slow query in get_posts
- How to query users by post count no less than 10
- Query postmeta based on meta_value, return array of post_id
- WP_Query: Query posts only if their access is restricted to logged user’s role
- Multiple wpostmeta.meta_key
- What argument does my function need to echo get_results() query results
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- WP Query to order posts by multiple meta fields
- How to connect database table to each registered wordpress user.
- Get a list of the last posts grouped by author and filtered by category
- How to return value from sql and display it
- WP_Query with several meta_query-statements and order by meta_value
- Parsing External Table Arguments
- wpdb LIKE request shows all database data
- How to add a custom field and incrementing value for all the published posts
- SQL query into to WP query
- Bulk delete comments, foreach loop
- How to make OR condition in WP_Query