wp_list_users_args
云策文档标注
概述
wp_list_users_args 是一个 WordPress 过滤器,用于修改 wp_list_users() 函数中获取用户列表的查询参数。它允许开发者自定义用户查询,如排序、排除特定用户等。
关键要点
- 过滤器名称:wp_list_users_args,用于过滤 wp_list_users() 的查询参数。
- 参数:$query_args(传递给 get_users() 的查询参数数组)和 $parsed_args(wp_list_users() 的默认参数与传入参数合并后的数组)。
- 支持多种参数,包括 orderby、order、number、exclude_admin、show_fullname、feed、feed_image、feed_type、echo、style、html、exclude、include 等,用于控制用户列表的显示和行为。
- 首次引入版本:WordPress 6.1.0。
代码示例
$query_args = apply_filters( 'wp_list_users_args', $query_args, $parsed_args );
原文内容
Filters the query arguments for the list of all users of the site.
Parameters
$query_argsarray-
The query arguments for get_users() .
More Arguments from get_users( … $args )
Arguments to retrieve users. See WP_User_Query::prepare_query() for more information on accepted arguments.
$parsed_argsarray-
The arguments passed to wp_list_users() combined with the defaults.
More Arguments from wp_list_users( … $args )
Array or string of default arguments.
orderbystringHow to sort the users. Accepts'nicename','email','url','registered','user_nicename','user_email','user_url','user_registered','name','display_name','post_count','ID','meta_value','user_login'. Default'name'.orderstringSorting direction for $orderby. Accepts'ASC','DESC'. Default'ASC'.numberintMaximum users to return or display. Default empty (all users).exclude_adminboolWhether to exclude the'admin'account, if it exists. Default false.show_fullnameboolWhether to show the user’s full name. Default false.feedstringIf not empty, show a link to the user’s feed and use this text as the alt parameter of the link.feed_imagestringIf not empty, show a link to the user’s feed and use this image URL as clickable anchor.feed_typestringThe feed type to link to, such as'rss2'. Defaults to default feed type.echoboolWhether to output the result or instead return it. Default true.stylestringIf'list', each user is wrapped in an<li>element, otherwise the users will be separated by commas.htmlboolWhether to list the items in HTML form or plaintext. Default true.excludestringAn array, comma-, or space-separated list of user IDs to exclude.includestringAn array, comma-, or space-separated list of user IDs to include.
Source
$query_args = apply_filters( 'wp_list_users_args', $query_args, $parsed_args );
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |