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
- User-edit role setting distinct from wp_capabilities? [closed]
- ORDER BY custom field value
- Sorting: custom query with orderby meta_value_num THEN by title
- Delete all subscribers from wp_users and wp_usermeta a few thousand at a time
- Problem with Hebrew characters in username
- Allowing an email as the username?
- Get the name of user who updated post
- Disable delete user
- Ordering posts having multiple post-meta date fields
- Order by first name
- Send activation email to user after signup [duplicate]
- wp_update_user() does not update user_data
- Custom Post type sort order not working in the admin area
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- Redirecting user after updating profile?
- How to add new custom field in default add user form through plugin
- ACF Upload Image in front-end with custom form
- Ascending sort order for monthly & category view, i.e. ?m=201204, ?cat=4
- Multiple authors with different “author roles”
- Exclude subscriber users from user list
- How can I check if a user’s email exists in the database
- Getting users by specific capability, not role
- Creating user in Firebase after WordPress user registration
- How to display total number of post done by user, it should display at authors page wordpress [duplicate]
- Delete User via Frontend
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Limit a number of users returned from sorting users by latest posts function
- Will wordpress tools import do everything I need to copy one site to another
- OAuth 2 and saving the authenticated user
- Accessing current users data within a plugin
- How to notify specific users when i’m posting/modifying a new post
- User description only displayed for logged user
- Allow users to create post without logging in?
- How to get the count
- WordPress Password security related questions
- Custom post type sorting: alphabetical order
- Assign random (and unique) user meta upon registration
- Display the line breaks in user bio without using html
- Querying specific table row by current user login
- Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’
- Display current user’s custom post meta in sidebar
- wp_dropdown_users() to include null value
- Adding more fields to the add user page on dashboard
- Allow users to upload flash videos?
- Allow Weak Passwords
- How can I clone a suscriber profile in wordpress
- Reading additional fields in PMPro
- How to put the ‘assign to new user’ select when you delete a user that has custom post type posts, but no normal posts
- How can I show a button in WordPress but make it unclickable unless logged in?
- Removing Malware
- How to display extra fields for user
- How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?
- wordpress Account Management generate password missing on my laptop
- Disable emails for new user registration
- Multiple sorting criteries (order by)
- Query for post term that matches user ID
- User email verification without a plugin, is it possible?
- List all users based on array of domains
- Custom post order when using OR relation
- Add method for tracking who referred new users
- Resend user activation mail
- Posts with no meta field do not appear when sorting by meta field
- Pre_Get_Posts order DESC not registering
- query_posts with sorting on a custom datestamp
- Retrieve New user’s ID
- List CPT by menu_order with children right after parent
- Restrict access to certain dashboard pages based on user id
- how to show logged in members username in wordpress content
- User agent stylesheet distorting site [closed]
- Order by a meta field in query loop
- Wordpres password as plain text in email