Instead of ‘request’ function, use this :
add_action('pre_user_query', 'user_column_orderby');
function user_column_orderby($userquery){
if('Votes'==$userquery->query_vars['orderby']) {
global $wpdb;
$userquery->query_from .= " LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb- >users.ID = alias.user_id) ";
$userquery->query_where .= " AND alias.meta_key = 'wp__user_like_count' ";
$userquery->query_orderby = " ORDER BY alias.meta_value ".($userquery->query_vars["order"] == "ASC" ? "asc " : "desc ");
}
}
Related Posts:
- ORDER BY custom field value
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Sorting posts by multiple values, combined
- Trying to sort and display categories(not posts) by custom field: ‘order’
- ORDER BY custom field value out of where clause
- WP_Query – Order results by meta value
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- How do I set the default admin sort order for a custom post type to a custom column?
- Orderby meta_value only returns posts that have existing meta_key
- Can I count the number of users matching a value in a multiple value key?
- Sort posts by custom field numeric value using dropdown
- Save custom user meta on registration
- How to get users by a custom field / by user meta data?
- Auto sort the wp-admin post list by a meta key
- How to order users alphabetically by their last name?
- How do you add a custom option to user data?
- get_pages sort alphabetically by meta value
- Archive sorting functions by custom fields (front-end)
- Trying to perform complex custom field query with order by set to field value
- Order Posts by Closest Numeric Values
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date?
- Order by custom field date with ASC order
- Show User Their Password
- How to update serialized data in the user meta data
- Order Custom post type loop by custom field (datepicker)
- Sorting within nested queries / multiple meta keys
- Ordering posts by anniversary using only day and month
- Order by Custom Field date not recognized
- Comments form custom fields order
- If value present, order posts by two consecutive custom fields
- Is it possible to order posts by two meta values?
- Displaying additional User Contact Information
- get_user_meta Short Profile Section
- Sort by posts that have a featured image?
- Custom column sorting in WordPress admin post table
- Sorting posts by custom fields in meta_query
- Separate table or usermeta
- meta_query for a string inside a meta field containing a comma-separated list
- How to update custom user meta field in wp?
- sort search results by custom fields using dropdown
- WordPress User Profile Upload – If page is saved file reset
- Sorting posts ordered by custom field value
- Sorting WordPress Posts via Custom Field Values?
- ACF: How to get the full field name (meta_key) by a field key?
- How do I create a column in Users list and display user data from custom registration field
- Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date
- How to save multiple options from a dropdown in user profile
- WP_User_Query pulling ACF to loop
- Users Select inside custom metabox
- query usermeta from custom field
- custom avatar removal
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Understanding the orderby in WP_Query?
- How to add upload video option in wordpress for user?
- Passing args to WP_User_Query am I using meta correctly?
- Change the sort order for posts to include custom field
- Alter main archive, to show posts with meta as last
- Sort custom post type by multiple custom fields
- Sort alphabetically by custom field
- How to save the date/time of last update of an extra user profile field?
- Change order of posts
- Meta query with multiple custom fields for archives page ordering problem
- Ordering posts by custom field named “date” in backend
- query posts custom field calculation value
- Sort WP_Query with numeric custom field
- WP Query – Is this correct?
- Hide custom column in admin template screen (Elementor) [closed]
- Using abs() with custom field in orderby statement
- wordpress custom loop ascending descending posts by custom field
- Show image if author meta (profile fields) exists outside loop
- Select custom posts by meta_value and sort by a different meta value
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- How to add fields in custom registration form, validate it and aave to db? [closed]
- check for duplicate user meta data before updating
- Custom Field Repeating When Using foreach
- Increment user meta data by 1 each time a page is visited
- change order of images attached to post
- Sortable Custom Columns not sorting correct
- Sort posts by clicks on download button
- Front-End User Profile
- Add custom column for custom field
- Get emails from users by custom field SQL
- award points to a user each time they update their cpt post
- How to update user profile custom fields
- Make a custom column sortable by a value from a different custom post type
- How To Show Get Adjacent Posts If Posts Are Sorted By Custom Field
- custom field in admin columns
- Order custom fields alphabetically
- Listing the most popular 8 city (custom fields) as used in posts
- How to sort by custom field value?
- Ordering by ‘Title’ OR ‘Custom Field’
- Custom Query Fields – Altering Meta Value
- How to order posts by number of Vimeo Likes
- Save custom field types with this function…?
- Problem with writting correctly a query posts args in WordPress
- How to query posts by month based on date custom field?
- Filter or order based on custom field
- Display Additional Info