您正在搜索的用户表列为user_email
$emails = new WP_User_Query( array(
\'fields\' => array( \'display_name\', \'user_email\', ), // you don\'t want everything, right?
\'orderby\' => \'email\', // \'user_email\' works as well
\'order\' => \'ASC\', // default: \'DESC\'
\'number\' => 10, // total amount of users to return
\'offset\' => 0, // use in combination with \'number\' to page results
\'search\' => \'*@*\',
\'search_columns\' => \'user_email\',
\'blog_id\' => get_current_blog_id(), // Multisite needs that, allows cross site search
\'role\' => \'subscriber\', // in case you want to exclude admins, etc.
\'exclude\' => array( 1, ), // Blacklist user IDs
) );
然后是过滤器
pre_user_query
你可以用它让全班同学都回来。您还可以使用它来调试查询:
<?php /* Plugin Name: Debug User Query */
add_filter( \'pre_user_query\', function( &$query )
{
var_dump( $GLOBALS[\'wp_query\']->last_query );
return $query;
} );