Block activity types from being added to activity stream in Buddypress

Sometimes it gets too spammy with all the Buddypress updates in the activity stream. Insert this code snippet in your functions.php or bp-custom.php to stop these updates from happening.

In this code you can filter out users who updated their profile, users who updated their avatar and those who’ve made new friendships. The list goes on with other self-explanatory elements.

bp-custom.php

function bp_activity_dont_save($activity_object)
	{
	$exclude = array(
           'updated_profile',
           'new_avatar',
           'new_member',
           'friendship_accepted',
           'friendship_created',
           'joined_group',
           'new_blog_comment',
           'bbp_topic_create', //bbpress
           'bbp_reply_create', //bbpress
	);

	// 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', 'bp_activity_dont_save', 10, 1);