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

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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.