BP_REST_Group_Invites_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-invites-endpoint.php
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 | 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 ) ); /** * 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_invites_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.