- Timestamp:
- 03/16/2021 06:53:43 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php
r12715 r12860 4 4 * 5 5 * @since 3.0.0 6 * @version 6.3.06 * @version 7.2.1 7 7 */ 8 8 … … 510 510 511 511 /** 512 * Makes sure the BP REST API groups/invites endpoint respects invite restrictions. 513 * 514 * @since 7.2.1 515 * 516 * @param bool|WP_Error $retval Whether the request can continue. 517 * @param WP_REST_Request $request The request sent to the API. 518 * @return bool|WP_Error 519 */ 520 function bp_nouveau_restrict_rest_group_invite_to_friends( $retval, $request ) { 521 if ( true === $retval && bp_is_active( 'friends' ) ) { 522 $group_id = $request->get_param( 'group_id' ); 523 $user_id = $request->get_param( 'user_id' ); 524 $inviter_id = $request->get_param( 'inviter_id' ); 525 526 if ( ! $inviter_id ) { 527 $inviter_id = bp_loggedin_user_id(); 528 } 529 530 if ( bp_nouveau_groups_get_group_invites_setting( $user_id ) && 'is_friend' !== BP_Friends_Friendship::check_is_friend( $inviter_id, $user_id ) ) { 531 $retval = new WP_Error( 532 'bp_rest_group_invite_cannot_create_item', 533 __( 'Sorry, you are not allowed to create the invitation as requested.', 'buddypress' ), 534 array( 535 'status' => rest_authorization_required_code(), 536 ) 537 ); 538 } 539 } 540 541 return $retval; 542 } 543 add_filter( 'bp_rest_group_invites_create_item_permissions_check', 'bp_nouveau_restrict_rest_group_invite_to_friends', 10, 2 ); 544 545 /** 512 546 * @since 3.0.0 513 547 */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)