I don’t think it will be possible using the User Query Class and probably not through MySQL either, because WordPress saves Arrays as Serialized data, so MySQL can’t interpret it like it could if it was a JSON format.
The only solution I can foresee is ordering it yourself using a loop in PHP – just query all users, then get it’s metadata, and loop through it ordering as you need.
To get best of performance, you can create an array containing the ordered IDs of the users, and save it as an option – or transient – and rebuilding this order index every time the user meta is changed. Something like this:
add_action( "added_user_meta", function($mid, $object_id, $meta_key, $meta_value) {
if ($meta_key == 'meta_key_you_are_ordering_by') {
//Get all users and loop through meta
}
});
Related Posts:
- WP_User_Query Orderby Not Working
- How can I pick a single post from the latest 3?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Weird orderby => post__in issue
- construct complex queries with WP User Query
- WP_User_Query orderby meta_val_num
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- How to get order of posts?
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- What kind of object type is WP_Query?
- Getting all user metadata from user
- How can I save an array from a random post sequence for later use?
- How to order posts tag by tag?
- How do I order pages and categories by ID or name in the same query?
- Getting an array out of WPQuery
- How to add custom query filters in WP_User_Query
- WP_Query ordered by custom field that is a date string?
- WP_Query sort by comment meta data
- Searching user meta using WP_User_Query
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- assign 2 $args to one wp_query
- Orderby = none not working [duplicate]
- Use Transient API to cache queries for all posts in all categories?
- WP_query ‘orderby=none’ Problem
- Order posts by date and then by custom field
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Revolution Slider Orderby Two Custom Fields
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- WP Meta Query for some meta (array) values
- Order by the results of a function with WP_query
- meta_query with array as value
- How to order posts in wp_query by a meta_value of the corresponding author
- Placing a div or img in between a post array using WP Query [closed]
- Show one post per author and limit query to 8 posts
- Order by menu structure
- WP_Query order by date in meta_value
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- Order WP Query posts by custom order calculated from post meta values
- How add a custom posttype name using ACF field to a query post array
- Custom Post order for homepage
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- WordPress WP_Query orderby being overwritten
- WP_Query Order by Specific Post ID First
- Order Posts by meta value AND published date
- How can I get an array of all IDs from the current queried object?
- Wp query orderby ‘title’ doesn’t work
- WP Query for variable taxonomies
- How can I order Wp_Query hierarchically?
- WP User Query get all authors with last name starting with specific letter
- How do I sort posts with multiple pages
- Sorting posts DESC based on the number of comments using WP_Query
- WP_User_Query unable to retreive all user at once
- Order WP_Query by multiple fields, subtracting them from one another
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- Minimize database queries to user tables?
- Orderby ASC changes to DESC in WP_Query
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- Adding an array from a query string to a WP meta_query
- Complex WP_Query order request: DESC by day, but then ASC by time
- How to set multiple `orderby` in query argument?
- WP_Query order result by date AND meta_value
- Order by title without taking into account ‘the’
- WP_Query orderby author__in
- WordPress search posts by author name with autocomplete
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- pagination with numbers for WP_User_Query
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order by empty custom field
- How to order posts by title after they have already been sorted by category
- Advanced ordering of query_posts
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- meta_value_num not ordering all items
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- Query all posts if multiple meta key don’t exist
- Get posts by list of post IDs ordered by those IDs?