WP_User_Query Generator

Home » WordPress Generators » WP_User_Query Generator

Related query generators WP query generator WP term query generator WP comment query generator Go back to all generators

The query variable to use for this snippet.
Add The Loop
Whether to add the display loop code to the snippet.
Don’t Return Total Count
Whether to return the total number of users found. True by default.
Super Admin
Whether to include super admins in the query.
Administrator
Whether to include administrators in the query.
Editor
Whether to include editors in the query.
Author
Whether to include authors in the query.
Contributor
Whether to include contributors in the query.
Subscriber
Whether to include subscribers in the query.
The custom role to include. Separated by commas. Example: role1,role2
Super Admin
Whether to exclude super admins in the query.
Administrator
Whether to exclude administrators in the query.
Editor
Whether to exclude editors in the query.
Author
Whether to exclude authors in the query.
Contributor
Whether to exclude contributors in the query.
Subscriber
Whether to exclude subscribers in the query.
The custom role to exclude. Separated by commas. Example: role1,role2
The blog ID to search. Defaults to the current blog.
The specific user IDs to include in the query. Seperated by commas.
The specific user IDs to exclude from the query. Seperated by commas.
The meta key to search for.
The meta value to search for.
How the meta field database value is compared with the value.
The number of users to return. Defaults to 100.
The number of users to offset the query. Defaults to 0.
The field to order the users by.
The order to return the users in.
The fields to return. Defaults to all fields.
ID
Whether to return the user ID.
Display Name
Whether to return the user’s display name.
User Name
Whether to return the user’s user name.
Login
Whether to return the user’s login.
Nicename
Whether to return the user’s nicename.
Email
Whether to return the user’s email.
URL
Whether to return the user’s URL.
Registered
Whether to return the user’s registration date.
Comma seperated list of custom fields to return.
                    $query_args = array(
);

$query = new WP_User_Query( $query_args );

if ( ! empty( $query ) && ! is_wp_error( $query ) ) {
	// The Loop
}
else {
	// no terms found
}
                

Sign up to save your WordPress snippets on WPTurbo.