Created
February 27, 2013 17:48
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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