BP_REST_Group_Membership_Request_Endpoint::get_items( WP_REST_Request $request )
Fetch pending group membership requests.
Description
Parameters
- $request
-
(Required) Full data about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php
public function get_items( $request ) { $args = array( 'item_id' => $request['group_id'], 'user_id' => $request['user_id'], 'per_page' => $request['per_page'], 'page' => $request['page'], ); // If the query is not restricted by group or user, limit it to the current user, if not an admin. if ( ! $args['item_id'] && ! $args['user_id'] && ! bp_current_user_can( 'bp_moderate' ) ) { $args['user_id'] = bp_loggedin_user_id(); } /** * Filter the query arguments for the request. * * @param array $args Key value array of query var to query value. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ $args = apply_filters( 'bp_rest_group_membership_requests_get_items_query_args', $args, $request ); $group_requests = groups_get_requests( $args ); $retval = array(); foreach ( $group_requests as $group_request ) { $retval[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $group_request, $request ) ); } $response = rest_ensure_response( $retval ); $response = bp_rest_response_add_total_headers( $response, count( $group_requests ), $args['per_page'] ); /** * Fires after a list of group membership request is fetched via the REST API. * * @param array of BP_Invitations $group_requests List of membership requests. * @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_membership_requests_get_items', $group_requests, $response, $request ); return $response; }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.