BP_REST_Group_Membership_Endpoint:: get_item (WP_REST_Request美元的请求)
检索小组成员。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-groups /类/ class-bp-rest-group-membership-endpoint.php
Public function get_items($request) {$group = $this-> group_endpoint ->get_group_object($request['group_id']);$ args =阵列(' group_id ' = >集团- > id、“group_role”= > $请求(“角色”),“类型”= > $请求“状态”,“per_page”= > $请求(“per_page”),“页面”= > $请求(“页面”),“search_term”= > $请求(“搜索”),“排除”= > $请求(“排除”),“exclude_admins_mods”= > (bool)美元请求(“exclude_admins”),'exclude_banned' => (bool) $request['exclude_banned'],);If (empty($args['exclude']) {$args['exclude'] = false;} if (is_null($args['search_terms']) {$args['search_terms'] = false;} /** *过滤请求的查询参数。* * @param array $args查询变量的关键值数组。@param WP_REST_Request $request发送给API的请求。* * @since 0.1.0 */ $args = apply_filters('bp_rest_group_members_get_items_query_args', $args, $request);数组$ retval = (); if ( ! empty( $request['scope'] ) ) { $group_potential_invites = $this->bp_rest_get_group_potential_invites( $group, $request ); if ( is_wp_error( $group_potential_invites ) ) { return $group_potential_invites; } else { $args['user_ids'] = $group_potential_invites; unset( $args['search_terms'] ); unset( $args['include'] ); unset( $args['exclude'] ); } $args['type'] = 'alphabetical'; // Actually, query it. $member_query = new BP_User_Query( $args ); $members = array_values( $member_query->results ); $retval = array(); foreach ( $members as $member ) { $retval[] = $this->prepare_response_for_collection( $this->members_endpoint->prepare_item_for_response( $member, $request ) ); } $response = rest_ensure_response( $retval ); $response = bp_rest_response_add_total_headers( $response, $member_query->total_users, $args['per_page'] ); } else { // Get our members. $members = groups_get_group_members( $args ); foreach ( $members['members'] as $member ) { $retval[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $member, $request ) ); } $response = rest_ensure_response( $retval ); $response = bp_rest_response_add_total_headers( $response, $members['count'], $args['per_page'] ); } /** * Fires after a list of group members are fetched via the REST API. * * @param array $members Fetched group members. * @param BP_Groups_Group $group The group object. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_group_members_get_items', $members, $group, $response, $request ); return $response; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |