BP_REST_Group_Membership_Request_Endpoint::prepare_item_for_response( BP_Invitation $invite, WP_REST_Request $request )
Prepares group invitation data to return as an object.
Description
Parameters
- $invite
-
(Required) Invite object.
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response)
Source
File: bp-groups/classes/class-bp-rest-group-membership-request-endpoint.php
public function prepare_item_for_response( $invite, $request ) { $data = array( 'id' => $invite->id, 'user_id' => $invite->user_id, 'invite_sent' => $invite->invite_sent, 'inviter_id' => $invite->inviter_id, 'group_id' => $invite->item_id, 'date_modified' => bp_rest_prepare_date_response( $invite->date_modified ), 'type' => $invite->type, 'message' => array( 'raw' => $invite->content, 'rendered' => apply_filters( 'the_content', $invite->content ), ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $invite, $request ) ); /** * Filter a group invite value returned from the API. * * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request Request used to generate the response. * @param BP_Invitation $invite The invite object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_group_membership_requests_prepare_value', $response, $request, $invite ); }
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.