GeneralRoleInclude & ExcludeNetworkSearchPaginationOrderCustom FieldsWhoTotal CountReturn FieldsOverviewUse this tool to create custom code for WordPress User Query with WP_User_Query class.UsageFill 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.ExamplesIf you are still learning how to use this tool, check out the following examples:Users from israel onlyGmail users among authorsAdministrator role users ordered by display nameRecently registered usersQuery Variable Name The variable used in the code.Show The Loop YesNo Show The Loop.User Role Choose...Super AdminAdministratorEditorAuthorContributorSubscriberCustom 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, 3Exclude Show specific list of users to be excluded.Comma separated list of ID's. e.g. 4, 5, 6Blog 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_urlNumber Number of users to show.Offset Number of users to displace or pass over.Order Choose...ASC - DefaultDESC Ascending or Descending order.Order by Choose...IDDisplay NameUser NameUser Login (Default)User NicenameUser EmailUser UrlUser Registered Datepost_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 - DefaultFalse The total count of users found.Return Fields Choose...All (Default)All With MetaCustom 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 );