A simple BuddyPress trick to avoid saving activities when members are becoming friends or when a member joins a group.


/* beginning of the code to paste in the functions.php of your active theme */
 
function imath_activivity_dont_save( $activity_object ) {
// friendship_created is fired when a member accepts a friend request
// joined_group is fired when a member joins a group.
$exclude = array( 'friendship_created', 'joined_group');
 
// if the activity type is empty, it stops BuddyPress BP_Activity_Activity::save() function
if( in_array( $activity_object->type, $exclude ) )
$activity_object->type = false;
 
}
 
add_action('bp_activity_before_save', 'imath_activivity_dont_save', 10, 1 );
 
/* end of the code to paste */
 

via A simple BuddyPress trick to avoid saving activities when members are becoming friends or when a member joins a group..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.