Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/16/2021 06:57:40 PM (5 years ago)
Author:
imath
Message:

Make sure Nouveau's Group invites visibility is applied to REST API

(trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php

    r12860 r12862  
    12711271    }
    12721272}
     1273
     1274/**
     1275 * Makes sure the Nouveau specific behavior about Group invites visibility is applied to the REST API.
     1276 *
     1277 * @since 7.2.1
     1278 *
     1279 * @param true|WP_Error   $retval  Whether the current user can list invites.
     1280 * @param WP_REST_Request $request The request sent to the API.
     1281 * @return true|WP_Error Whether the current user can list invites.
     1282 */
     1283function bp_nouveau_rest_group_invites_get_items_permissions_check( $retval, $request ) {
     1284    if ( is_wp_error( $retval ) ) {
     1285        $group_id = (int) $request['group_id'];
     1286
     1287        if ( groups_is_user_member( bp_loggedin_user_id(), $group_id ) ) {
     1288            $retval = true;
     1289        }
     1290    }
     1291
     1292    return $retval;
     1293}
     1294add_filter( 'bp_rest_group_invites_get_items_permissions_check', 'bp_nouveau_rest_group_invites_get_items_permissions_check', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.