Remove joined group notification from sitewide activity

This is very little code snippet that will help you to hide some activity notification from the sitewide activity page. When someone joins in a group, we see a notification in sitewide activity page says, “Someone joined the group ABC”.

Screen Shot 2014-09-26 at 7.43.47 PM

This not that bad, but if your site is attacked by spam users, your activity feed will be flooded with spam notification. So why don’t just hide it? :) Here is the code snippet:

You may also read:  Enable css for HTML5 tags in Older Internet Explorer: HTML5 – The Beautiful Butterfly! Part 3
add_action('bp_has_activities','my_denied_activity_new_member', 999, 2 );
function my_denied_activity_new_member( $a, $activities ){
foreach( $activities->activities as $key => $activity ){
if ( $activity->type =='joined_group') {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;

You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

You may also read:  Some Security Issue (php)

You can do the same for other notification type. If you don’t know the type, in the above code just use:

You will get all the types that are coming in your activity field.

Enjoy! :)

You may also like...

Leave a Reply

%d bloggers like this: