BP_REST_Attachments_Member_Cover_Endpoint::prepare_item_for_response( string $cover_url, WP_REST_Request $request )

Prepares user cover to return as an object.

Description

Parameters

$cover_url

(Required) User cover url.

$request

(Required) Full details about the request.

Return

(WP_REST_Response)

Source

File: bp-members/classes/class-bp-rest-attachments-member-cover-endpoint.php

	public function prepare_item_for_response( $cover_url, $request ) {
		$data = array(
			'image' => $cover_url,
		);

		$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 );

		/**
		 * Filter a user cover value returned from the API.
		 *
		 * @param WP_REST_Response $response Response.
		 * @param WP_REST_Request $request Request used to generate the response.
		 * @param string $cover_url Group cover url.
		 *
		 * @since 0.1.0
		 */
		return apply_filters( 'bp_rest_attachments_member_cover_prepare_value', $response, $request, $cover_url );
	}

Changelog

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.