General Role Include & Exclude Network Search Pagination Order Custom Fields Who Total Count Return Fields Overview Use this tool to create custom code for WordPress User Query with WP_User_Query class. Usage Fill in the user-friendly form. Click the “Update Code” button. Copy the code to your project. Or save it as a snippet and share with the community. Examples If you are still learning how to use this tool, check out the following examples: Users from israel only Gmail users among authors Administrator role users ordered by display name Recently registered users Query Variable Name The variable used in the code. Show The Loop Yes No Show The Loop. User Role Choose... Super Admin Administrator Editor Author Contributor Subscriber Custom User Role Show users associated with certain role. Custom User Role Show users associated with custom role. Include Show specific list of users to be included.Comma separated list of ID's. e.g. 1, 2, 3 Exclude Show specific list of users to be excluded.Comma separated list of ID's. e.g. 4, 5, 6 Blog ID Show users associated with certain blog on the network. Search Keyword Show users based on a possible keyword. Search Columns Comma separated list of database table columns to matches the search keywords. e.g. id, user_login, user_nicename, user_email, user_url Number Number of users to show. Offset Number of users to displace or pass over. Order Choose... ASC - Default DESC Ascending or Descending order. Order by Choose... ID Display Name User Name User Login (Default) User Nicename User Email User Url User Registered Date post_count Sort retrieved users by. Meta Query No save snippets... Select from your saved WP_Meta_Query snippets. Which users Which users to query. Currently only "authors" is supported. Default is all users. Total Count Choose... True - Default False The total count of users found. Return Fields Choose... All (Default) All With Meta Custom Fields Set the fields you want to return. Custom Return Fields Comma separated list of fields to return. e.g. id, user_login, user_nicename, user_email, user_url, user_registered Update Code Save Snippet
// WP_User_Query arguments $args = array( ); // The User Query $user_query = new WP_User_Query( $args );