Changeset 12629 for trunk/src/bp-groups/bp-groups-activity.php
- Timestamp:
- 04/21/2020 06:12:25 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-activity.php
r12590 r12629 619 619 620 620 /** 621 * Function used to determine if a user can delete a group activity item. 622 * 623 * Used as a filter callback to 'bp_activity_user_can_delete'. 624 * 625 * @since 6.0.0 626 * 627 * @param bool $retval True if item can receive comments. 628 * @param object $activity Activity item being checked. 629 * @return bool 630 */ 631 function bp_groups_filter_activity_user_can_delete( $retval, $activity ) { 632 // Bail if no current user. 633 if ( ! is_user_logged_in() ) { 634 return $retval; 635 } 636 637 if ( isset( $activity->component ) || 'groups' !== $activity->component ) { 638 return $retval; 639 } 640 641 // Trust the passed value for administrators. 642 if ( bp_current_user_can( 'bp_moderate' ) ) { 643 return $retval; 644 } 645 646 // Group administrators or moderators can delete content in that group that doesn't belong to them. 647 $group_id = $activity->item_id; 648 if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) { 649 $retval = true; 650 } 651 652 return $retval; 653 } 654 add_filter( 'bp_activity_user_can_delete', 'bp_groups_filter_activity_user_can_delete', 10, 2 ); 655 656 /** 621 657 * Function used to determine if a user can comment on a group activity item. 622 658 *
Note: See TracChangeset
for help on using the changeset viewer.