Ok, solved this. I had to use the posts_clauses
filter and the following code:
function assigned_to_orderby( $clauses, $wp_query ) {
global $wpdb;
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID={$wpdb->postmeta}.post_id
LEFT OUTER JOIN {$wpdb->users} ON {$wpdb->users}.ID={$wpdb->postmeta}.meta_value
";
$clauses['where'] .= " AND ({$wpdb->postmeta}.meta_key = 'assignee')";
$clauses['groupby'] = "{$wpdb->postmeta}.post_id";
$clauses['orderby'] = "GROUP_CONCAT({$wpdb->users}.user_login ORDER BY {$wpdb->users}.user_login ASC) ";
$clauses['orderby'] .= ( 'DESC' == strtoupper( $_GET['order'] ) ) ? 'DESC' : 'ASC';
return $clauses;
}
Adapted from http://scribu.net/wordpress/sortable-taxonomy-columns.html
Related Posts:
- How to order users alphabetically by their last name?
- meta_query orderby sort multiple keys
- Sort users by custom user meta value
- alphabetically order role drop-down selection in dashboard
- order users with drag’n’drop?
- Getting users who registered 360 days from current date
- Querying Email Addresses for a List of Users with Same Last Name?
- How to delete users with no order history through phpmyadmin sql?
- What is proper way to store info such as user marking a post as favorite? In post meta or user meta?
- Column Sorting Code on users.php
- How change user type from contributor to author
- WordPress SQL Issue not returning correct reselts
- cannot get user_registered date from get_user_meta
- How to copy user_nicename value into user_login
- How can I prevent certain custom roles from seeing other custom roles on the user list page?
- Sort custom posts in archive by multiple values: date AND meta key
- SQL Bulk update all WordPress user’s nicknames to firstname + lastname format
- Get usermeta info from sql query
- SELECT from wp_users, get Displayname too
- how to delete in phpmyadmin sql – all users with certain condition and all dependencies
- How to get image path from id using SQL
- SQL to set Display Name to First Name + Last Name
- sort title descending with title with number
- Safely changing UserID’s, re-using deleted UserID’s and automatically using deleted userID’s instead of an increment
- Insert query not working for non-logged in user
- User list order by user meta
- Sorting Users page admin column with ACF field
- I try to add informations to User profile
- List all users based on array of domains
- Users set passwords but cannot login
- Store extra user values permanently
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Custom post order when using OR relation
- How do I change the user via SQL?
- post acces for guests / unregistered users only
- Add method for tracking who referred new users
- How do I Limit the number of pages a non-subscriber can see?
- Track users views
- user added by(who added this user)
- New User ID not working in custom function with user_register hook
- Add an ‘edit profile’ page with Genesis
- Resend user activation mail
- Exclude Current user email and send notification
- Registered access area
- Cloning admin pages like users.php
- Username has been exposed
- force registered user as seller
- Custome column sort by date not title
- Subscriber role – blank page
- Set user role on registration so can upload file to own media library area
- Display Users and user url’s
- custom login form, guide me
- Ordering list of users by last name and then by first name
- Edit dashboard based on user ID
- What’s the most secure way to grant a user permission to update in a multisite?
- is_user_logged_in() not working after domain change
- User email not being changed (cached?) until next page load (frontend)
- Error when send reset password
- Manage user profiles with WordPress
- Separate Profiles for Users
- How To Find The ID Of All Registered Users?
- WP Query to order posts by multiple meta fields
- Not able to call value in the core files
- How to get only 1 role from user
- Get the author registration date in the header.php file
- Front end login and page restriction
- How to disable users changing their display_name?
- User “none” role
- Re-order posts inside tax query
- Posts with no meta field do not appear when sorting by meta field
- User count only for role frontend vendor
- Disallow user registration/checkout via Hotmail/Yahoo
- logged_in user outside of wordpress loop
- Query category-specific, paginated posts and allow viewer to change sort order
- Pre_Get_Posts order DESC not registering
- Limit roles displayed in users.php depending on custom role
- User management missing after migration to new host
- Sorting: custom query with orderby meta_value_num THEN by title
- query_posts with sorting on a custom datestamp
- Add new user and user bio at same time
- Fetching posts that match a User Profile setting
- Migrating Users along with their password
- How to create a link to a user’s profile page
- How to sort post_meta in edit.php?
- show count author post today
- orderby in WP_query doesn’t works
- How i will get the images of highest scored users?
- Are there any hook or filter when adding new user in WordPress?
- Sorting meta box values by start- and enddate and all dates in between
- Creating Custom user type just like custom post
- Validate user meta and redirect
- Retrieve New user’s ID
- Add a column before username in the users profile table
- Designing a member area on my site
- Link to Authors blog posts
- Changing user_login ends current session
- Let admin users edit member profiles from front end
- Will mass deleting WP Users then reimporting CSV with the same userid break WP?
- view and update form only for registered users
- Does WordPress Need BuddyPress to Handle Large Amounts of Users?