exclude admin in activitystream
-
Is it possible to exclude all activities from the admin account in the activity stream?
-
something like this may work – just enter in the user_id of the admin account and the activity items are removed from the activity array.
function my_denied_admin_activity( $a, $activities ) {
//if admin we want to know
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
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', 'my_denied_admin_activity', 10, 2 );@nuprn1 this code is promising, but results in an erratic number of activity stream items… For example, if your activity stream is set to 20 items, and 11 of them are admin items, you only display 9 items total. Is there any way to “normalize” the number of activity stream items?
Brajesh code for “Stealth Mode for Admins” also works for me BP 1.2.3/WPMU 2.9.2.
Just add to bp-custom.php
add_action("plugins_loaded","bpdev_init_sm_mode");
function bpdev_init_sm_mode(){
if(is_site_admin())
remove_action("wp_head","bp_core_record_activity");//id SM is on, remove the record activity hook
}That approach is OK if you definitely do not care about recording admin activity for other uses. If you want to keep the activity stream recording as usual, you would have to go with an approach similar to the “my_admin_denied_activity” function.
Thank you for pointing that out 3sixty. I use my Site Admin account to do all backend stuff. I use my Admin account to socialize
Once my BuddyPress Privacy Component is out, Site Admin’s will easily be able to exclude their activity from the stream! And, since I know people will ask:
https://buddypress.org/forums/topic/privacy-component-where-is-it
ah.. great!
I’ll wait on this one.
Thanks everybody .. for your reactions.
I figured out a clean way to exclude blog post comments and forum replies from the main activity stream by essentially editing the bp-activity-classes.php file (not ideal, but it’s a start)
It’s a little off topic so I’ll continue the discussion on the previous thread where this came up:
https://buddypress.org/forums/topic/excluding-blog-post-comments-from-activity-stream-page
My aforementioned Privacy Component will offer fine-grained filtering of any activity stream content–that is as long as the plugin developer made sure to register all the activity stream actions for their component. No need for fancy bp-custom.php functions, core hacks, and the like.
My aforementioned Privacy Component will offer fine-grained filtering of any activity stream content–that is as long as the plugin developer made sure to register all the activity stream actions for their component. No need for fancy bp-custom.php functions, core hacks, and the like.
wow… nice!! Another great plugin to melt our heads.
- The topic ‘exclude admin in activitystream’ is closed to new replies.