Skip to content

Instantly share code, notes, and snippets.

@slaFFik
Forked from BoweFrankema/block-activity-types.php
Last active February 3, 2020 11:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaFFik/044cb43c0871e48cf341 to your computer and use it in GitHub Desktop.
Save slaFFik/044cb43c0871e48cf341 to your computer and use it in GitHub Desktop.
BuddyPress Activity - don't save certain activity types
<?php
//Block certain activity types from being added
function bp_activity_dont_save( $activity_object ) {
$exclude = array(
'updated_profile',
'new_member',
'new_avatar',
'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', 'bp_activity_dont_save', 10, 1 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment