BP_REST_Attachments_Blog_Avatar_Endpoint::get_item_permissions_check( WP_REST_Request $request )

Checks if a given request has access to get a blog avatar.

Description

Parameters

$request

(Required) Full details about the request.

Return

(bool|WP_Error)

Source

File: bp-blogs/classes/class-bp-rest-attachments-blog-avatar-endpoint.php

	public function get_item_permissions_check( $request ) {
		$retval     = true;
		$this->blog = $this->blogs_endpoint->get_blog_object( $request['id'] );

		if ( true === $retval && ! is_object( $this->blog ) ) {
			$retval = new WP_Error(
				'bp_rest_blog_invalid_id',
				__( 'Invalid group ID.', 'buddyboss' ),
				array(
					'status' => 404,
				)
			);
		}

		if ( true === $retval && ! buddypress()->avatar->show_avatars ) {
			$retval = new WP_Error(
				'bp_rest_attachments_blog_avatar_disabled',
				__( 'Sorry, blog avatar is disabled.', 'buddyboss' ),
				array(
					'status' => 500,
				)
			);
		}

		/**
		 * Filter the blog avatar `get_item` permissions check.
		 *
		 * @since 0.1.0
		 *
		 * @param bool|WP_Error   $retval  Returned value.
		 * @param WP_REST_Request $request The request sent to the API.
		 */
		return apply_filters( 'bp_rest_attachments_blog_avatar_get_item_permissions_check', $retval, $request );
	}

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.