Skip to:
Content
Pages
Categories
Search
Top
Bottom

exclude admin in activitystream

  • Avatar of Stef
    Stef
    Participant

    @stef78

    Is it possible to exclude all activities from the admin account in the activity stream?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    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 );

    Avatar of 3sixty
    3sixty
    Participant

    @3sixty

    @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?

    Avatar of @mercime
    @mercime
    Keymaster

    @mercime

    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
    }

    Avatar of 3sixty
    3sixty
    Participant

    @3sixty

    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.

    Avatar of @mercime
    @mercime
    Keymaster

    @mercime

    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 :-)

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    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:

    http://buddypress.org/forums/topic/privacy-component-where-is-it

    Avatar of Stef
    Stef
    Participant

    @stef78

    ah.. great!

    I’ll wait on this one.

    Thanks everybody .. for your reactions.

    Avatar of 3sixty
    3sixty
    Participant

    @3sixty

    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:

    http://buddypress.org/forums/topic/excluding-blog-post-comments-from-activity-stream-page

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    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.

    Avatar of 3sixty
    3sixty
    Participant

    @3sixty

    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.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.