BP_REST_Signup_Endpoint::prepare_item_for_response( BP_Signup $signup, WP_REST_Request $request )
Prepares signup to return as an object.
Description
Parameters
- $signup
-
(Required) Signup object.
- $request
-
(Required) Full data about the request.
Return
(WP_REST_Response)
Source
File: bp-members/classes/class-bp-rest-signup-endpoint.php
public function prepare_item_for_response( $signup, $request ) { $data = array( 'id' => $signup->id, 'user_login' => $signup->user_login, 'user_name' => $signup->user_name, 'registered' => bp_rest_prepare_date_response( $signup->registered ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; if ( 'edit' === $context ) { $data['activation_key'] = $signup->activation_key; $data['user_email'] = $signup->user_email; } $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); // @todo add prepare_links $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $signup ) ); /** * Filter the signup response 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_Signup $signup Signup object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_signup_prepare_value', $response, $request, $signup ); }
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.