Skip to content

Instantly share code, notes, and snippets.

@imath
Created February 27, 2013 17:48
Show Gist options
  • Save imath/5049922 to your computer and use it in GitHub Desktop.
Save imath/5049922 to your computer and use it in GitHub Desktop.
A simple BuddyPress trick to avoid saving activities when members are becoming friends or when a member joins a group.
<?php
/* 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 */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment