bp_groups_leave_group_delete_recent_activity( int $group_id, int $user_id )
Delete group member activity if they leave or are removed within 5 minutes of membership modification.
Description
If the user joined this group less than five minutes ago, remove the joined_group activity so users cannot flood the activity feed by joining/leaving the group in quick succession.
Parameters
- $group_id
-
(Required) ID of the group.
- $user_id
-
(Required) ID of the user leaving the group.
Source
File: bp-groups/bp-groups-activity.php
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 | function bp_groups_leave_group_delete_recent_activity( $group_id , $user_id ) { // Bail if Activity component is not active. if ( ! bp_is_active( 'activity' ) ) { return ; } // Get the member's group membership information. $membership = new BP_Groups_Member( $user_id , $group_id ); // Check the time period, and maybe delete their recent group activity. if ( time() <= strtotime ( '+5 minutes' , (int) strtotime ( $membership ->date_modified ) ) ) { bp_activity_delete( array ( 'component' => buddypress()->groups->id, 'type' => 'joined_group' , 'user_id' => $user_id , 'item_id' => $group_id ) ); } } |
Changelog
Version | Description |
---|---|
BuddyPress 1.9.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.