BP_REST_Messages_Endpoint::get_current_user_permissions( object $recipient, WP_REST_Request $request )

Get current user’s permission.

Description

Parameters

$recipient

(Required) The recipient object.

$request

(Required) Full details about the request.

Return

(array) Get current user permission.

Source

File: bp-messages/classes/class-bp-rest-messages-endpoint.php

2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
public function get_current_user_permissions( $recipient, $request ) {
 
    $retval = array(
        'unread'          => true,
        'delete_messages' => true,
        'delete_thread'   => bp_user_can(
            $recipient->user_id,
            'bp_moderate',
            array(
                'site_id' => bp_get_root_blog_id(),
            )
        ),
    );
 
    if ( isset( $recipient->is_hidden ) ) {
        $retval['hide_thread'] = true;
    }
 
    return $retval;
}

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.