$WP_User_Query = new WP_User_Query();
$WP_User_Query->prepare_query( $query );
$query(строка|массив)
Array or string of query parameters.
По умолчанию: array()
blog_id(int)
The site ID. По умолчанию: current site
role(строка|string[])
An array or a comma-separated list of role names that users must match to be included in results. Note that this is an inclusive list: users must match each role. По умолчанию: ''
role__in(string[])
An array of role names. Matched users must have at least one of these roles. По умолчанию: empty array
role__not_in(string[])
An array of role names to exclude. Users matching one or more of these roles will not be included in results. По умолчанию: empty array
meta_key(строка|string[])
Meta key or keys to filter by.
meta_value(строка|string[])
Meta value or values to filter by.
meta_compare(строка)
MySQL operator used for comparing the meta value. See WP_Meta_Query::__construct() for accepted values and default value.
meta_compare_key(строка)
MySQL operator used for comparing the meta key. See WP_Meta_Query::__construct() for accepted values and default value.
meta_type(строка)
MySQL data type that the meta_value column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.
meta_type_key(строка)
MySQL data type that the meta_key column will be CAST to for comparisons. See WP_Meta_Query::__construct() for accepted values and default value.
meta_query(массив)
An associative array of WP_Meta_Query arguments. See WP_Meta_Query::__construct() for accepted values.
capability(строка|string[])
An array or a comma-separated list of capability names that users must match to be included in results. Note that this is an inclusive list: users must match each capability. Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. По умолчанию: ''
capability__in(string[])
An array of capability names. Matched users must have at least one of these capabilities. Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. По умолчанию: empty array
capability__not_in(string[])
An array of capability names to exclude. Users matching one or more of these capabilities will not be included in results. Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. По умолчанию: empty array
include(int[])
An array of user IDs to include. По умолчанию: empty array
exclude(int[])
An array of user IDs to exclude. По умолчанию: empty array
search(строка)
Search keyword. Searches for possible string matches on columns. When $search_columns is left empty, it tries to determine which column to search in based on search string. По умолчанию: ''
search_columns(string[])
Array of column names to be searched. Accepts 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name'. По умолчанию: empty array
orderby(строка|массив)
Field(s) to sort the retrieved users by. May be a single value, an array of values, or a multi-dimensional array with fields as keys and orders ('ASC' or 'DESC') as values. Accepted values are:
'ID'
'display_name' (or 'name')
'include'
'user_login' (or 'login')
'login__in'
'user_nicename' (or 'nicename')
'nicename__in'
'user_email (or 'email')
'user_url' (or 'url')
'user_registered' (or 'registered')
'post_count'
'meta_value'
'meta_value_num'
The value of $meta_key
An array key of $meta_query To use 'meta_value' or 'meta_value_num', $meta_key must be also be defined. По умолчанию: 'user_login'
order(строка)
Designates ascending or descending order of users. Order values passed as part of an $orderby array take precedence over this parameter. Accepts 'ASC', 'DESC'. По умолчанию: 'ASC'
offset(int)
Number of users to offset in retrieved results. Can be used in conjunction with pagination.
number(int)
Number of users to limit the query for. Can be used in conjunction with pagination. Value -1 (all) is supported, but should be used with caution on larger sites. По умолчанию: -1 (all users)
paged(int)
When used with number, defines the page of results to return. По умолчанию: 1
count_total(true|false)
Whether to count the total number of users found. If pagination is not needed, setting this to false can improve performance. По умолчанию: true
fields(строка|string[])
Which fields to return. Single or all fields (string), or array of fields. Accepts:
'ID'
'display_name'
'user_login'
'user_nicename'
'user_email'
'user_url'
'user_registered'
'user_pass'
'user_activation_key'
'user_status'
'spam' (only available on multisite installs)
'deleted' (only available on multisite installs)
'all' for all fields and loads user meta.
'all_with_meta' Deprecated. Use 'all'. По умолчанию: 'all'
who(строка)
Deprecated, use $capability instead. Type of users to query. Accepts 'authors'. По умолчанию: empty (all users)
has_published_posts(true|false|string[])
Pass an array of post types to filter results to users who have published posts in those post types. true is an alias for all public post types.
nicename(строка)
The user nicename. По умолчанию: ''
nicename__in(string[])
An array of nicenames to include. Users matching one of these nicenames will be included in results. По умолчанию: empty array
nicename__not_in(string[])
An array of nicenames to exclude. Users matching one of these nicenames will not be included in results. По умолчанию: empty array
login(строка)
The user login. По умолчанию: ''
login__in(string[])
An array of logins to include. Users matching one of these logins will be included in results. По умолчанию: empty array
login__not_in(string[])
An array of logins to exclude. Users matching one of these logins will not be included in results. По умолчанию: empty array
cache_results(true|false)
Whether to cache user information. По умолчанию: true
Global. WP_Roles. $wp_roles WordPress role management object.
Список изменений
С версии 3.1.0
Введена.
С версии 4.1.0
Added the ability to order by the include value.
С версии 4.2.0
Added 'meta_value_num' support for $orderby parameter. Added multi-dimensional array syntax for $orderby parameter.
С версии 4.3.0
Added 'has_published_posts' parameter.
С версии 4.4.0
Added 'paged', 'role__in', and 'role__not_in' parameters. The 'role' parameter was updated to permit an array or comma-separated list of values. The 'number' parameter was updated to support querying for all users with using -1.
С версии 4.7.0
Added 'nicename', 'nicename__in', 'nicename__not_in', 'login', 'login__in', and 'login__not_in' parameters.
С версии 5.1.0
Introduced the 'meta_compare_key' parameter.
С версии 5.3.0
Introduced the 'meta_type_key' parameter.
С версии 5.9.0
Added 'capability', 'capability__in', and 'capability__not_in' parameters. Deprecated the 'who' parameter.
С версии 6.3.0
Added 'cache_results' parameter.
Код WP_User_Query::prepare_query() WP User Query::prepare query WP 6.7.1