Created
November 6, 2021 19:41
-
-
Save vkartk/51d442fc1ed55720d61875388f651804 to your computer and use it in GitHub Desktop.
Hide admin activity for BuddyPress / BuddyBoss
This file contains 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
// hide admin's activities from all activity feeds | |
function ( $a, $activities ) { | |
// ... but allow admin to see his activities! | |
if ( is_super_admin() ) | |
return $activities; | |
foreach ( $activities->activities as $key => $activity ) { | |
// ID's to exclude, separated by commas. ID 1 is always the superadmin | |
if ( $activity->user_id == 1 ) { | |
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; | |
} | |
} | |
// Renumber the array keys to account for missing items | |
$activities_new = array_values( $activities->activities ); | |
$activities->activities = $activities_new; | |
return $activities; | |
} | |
add_action( 'bp_has_activities', 'buddy_hide_admin_activity', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment