How to order custom user list columns by datetime?
I think you could simplify this a lot by using the pre_get_users hook, instead of working directly with the complicated SQL within the pre_user_query hook. Try something like: add_action( ‘pre_get_users’, function( \WP_User_Query $q ) { $qv = &$q->query_vars; if( isset( $qv[‘orderby’] ) && ‘test_date’ === $qv[‘orderby’] ) { // Custom meta query $qv[‘meta_query’] = [ … Read more