diff --git src/bp-groups/bp-groups-activity.php src/bp-groups/bp-groups-activity.php
index 1cafacd66..ce89642fd 100644
|
|
function groups_post_update( $args = '' ) { |
651 | 651 | */ |
652 | 652 | function bp_groups_filter_activity_user_can_delete( $retval, $activity ) { |
653 | 653 | // Bail if no current user. |
| 654 | // Todo: add second conditional statement to check the state to allow group activity deletions. |
| 655 | // e.g., "|| ! bp_enable_group_activity_deletions()". |
654 | 656 | if ( ! is_user_logged_in() ) { |
655 | 657 | return $retval; |
656 | 658 | } |
657 | 659 | |
658 | | if ( isset( $activity->component ) || 'groups' !== $activity->component ) { |
| 660 | // The second conditional statement does not allow "site admin" activity posts to be deleted by "non site admins". |
| 661 | if ( bp_current_user_can( 'bp_moderate' ) || bp_user_can( $activity->user_id, 'bp_moderate' ) ) { |
659 | 662 | return $retval; |
660 | 663 | } |
661 | 664 | |
662 | | // Trust the passed value for administrators. |
663 | | if ( bp_current_user_can( 'bp_moderate' ) ) { |
664 | | return $retval; |
665 | | } |
| 665 | $bp = buddypress(); |
666 | 666 | |
667 | | // Group administrators or moderators can delete content in that group that doesn't belong to them. |
668 | | $group_id = $activity->item_id; |
669 | | if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) { |
670 | | $retval = true; |
| 667 | // Confine group activity deletion to the confines of the respective group where it is allowed. |
| 668 | if ( ! empty( $bp->groups->current_group->id ) ) { |
| 669 | $group_id = $bp->groups->current_group->id; |
| 670 | |
| 671 | // Todo: break this out into additional conditionals that provide granularity as to who can to what, when. |
| 672 | if ( groups_is_user_creator( bp_loggedin_user_id(), $group_id ) || groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) { |
| 673 | $retval = true; |
| 674 | } |
671 | 675 | } |
672 | 676 | |
673 | 677 | return $retval; |