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
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- Sorting: custom query with orderby meta_value_num THEN by title
- Custom WP_Query order by post_meta and (author) user_meta
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Getting all user metadata from user
- How to order posts tag by tag?
- How to add custom query filters in WP_User_Query
- WP_Query sort by comment meta data
- Searching user meta using WP_User_Query
- Order posts by tags count?
- Orderby = none not working [duplicate]
- 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
- Order by the results of a function with WP_query
- How to order posts in wp_query by a meta_value of the corresponding author
- Order by menu structure
- WP_Query order by date in meta_value
- 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
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- How can I get an array of all IDs from the current queried object?
- Wp query orderby ‘title’ doesn’t work
- 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
- Minimize database queries to user tables?
- 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
- Complex WP_Query order request: DESC by day, but then ASC by time
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Order by summing multiple values
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order ascending is ignored in meta query?
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- Debugging wp_query orderby for taxonomy
- Advanced WP_Query with meta_query, orderby?
- Does meta_value (array) work with ‘orderby’?
- How to Order a list of taxonomies? orderby?
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- WP_Query with page_ids in arguments without a result
- Related Posts Excluding Certain Categories
- Query using string from custom field as array value
- Filtering by multiple conditions in the loop
- Multiple meta query from array
- Category based on post id
- Randomly select one of last 3 posts
- WP_Query orderby random do not repeat infinite scroll – one loop
- how to retrieve WP_Query without ordering by date [duplicate]
- meta_query returning excluded result
- orderby ignored by wp_query
- WP_Query orderby
- Replace wp_query with wp_user_query
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- How can I order a post query’s results based on the number of matching taxonomy terms?
- How to sort store location by specific category order in WP store locations
- Counting instances of words in the results of a post query
- Random users always showing same 8 users
- Trouble with serialized metadata
- WP_Query random ordering not working since 5.4
- What code to use in an array to call the current sub-category?
- Meta query orderby meta_value_num sorting by role first
- Order by meta date with a thousanth of a second defaults to post order
- WP Query with meta queries
- WP Query. Ordering posts by another post types meta
- Repeat array inside array through while loop
- Best way to query posts and order by relevancy to query
- Related Post by Tags Code
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- wp_query sorting – one specific meta_key value at last and then sort by create date
- query_posts based on a meta_key
- Display three sequential posts on each page load, without repeating previous
- Order posts by more than one variable (meta_key and publish date AND time)
- Create custom order sortby based on array of id
- Sort by meta key within same day
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Order Custom Field by Price
- Search Functionality broken by the wp 4.2 update
- How to sort a WP_Query array by post_name after an array_merge();
- WordPress WP_Query Array Custom search via taxonomies
- Order by multiple meta keys on wordpress
- Order posts with custom taxonomy array
- Sort Posts with custom meta key by default which is currently set as optional
- WP_Query with several meta_query-statements and order by meta_value
- Get posts that were most recently tagged
- WordPress WP_User_Query ignores the `meta_query` when called from an Ajax function
- Why does wp_query only display the most recent post when using order ASC?
- new WP_Query with order args – no more distinction between categories