Created
October 10, 2012 19:29
-
-
Save staylor/3867859 to your computer and use it in GitHub Desktop.
Unfuck User Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'pre_user_query', 'fix_users' ); | |
function fix_users( &$query ) { | |
global $wpdb; | |
if ( 'authors' !== $query->query_vars['who'] ) | |
return; | |
$query->query_vars['fields'] = array( 'ID', 'display_name' ); | |
$query->query_fields = 'ID, display_name'; | |
$query->query_from = "FROM {$wpdb->users}"; | |
$emails = '"' . join( '","', $GLOBALS['super_admins'] ) . '"'; | |
$query->query_where = "WHERE ID < 10000 OR user_login IN ($emails)"; | |
$query->query_orderby = 'ORDER BY display_name ASC'; | |
$query->query_limit = ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a specific example, alter the WHERE to your own flavor