Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filtering out Activity Stream stuff

  • This is a simple rehash of some old code by @nuprn1 (thanks Rich), and filters out various activity messages to keep the stream from clogging up. Put the following in your theme’s functions.php file, and modify as desired;

    // Remove (hide) various activities from streams.
    function my_hidden_activities($a, $activities) {
    //if admin we want to know
    //if (is_site_admin())
    // return $activities;

    $nothanks = array(“new_blog_post”, “created_group”, “joined_group”, “new_member”, “friendship_created”, “activity_liked”);

    foreach ($activities->activities as $key => $activity) {
    if (in_array($activity->type, $nothanks, true)) {
    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_hidden_activities’, 10, 2 );

Viewing 19 replies - 1 through 19 (of 19 total)
  • if a site owner does not care about certain activity items at all – block em:
    https://wordpress.org/extend/plugins/buddypress-block-activity-stream-types/

    @nuprn1; Yep, that works, and saves a little db space too. However, I discovered today that your Block Activity plugin causes Group creation to fail at the final stage, though as I said in a note to you, it could be a theme clash for all I know.

    I think it’s useful to have the details still in the db, and so do friends. Enabling the is_admin() part then allows us to see all activity. It’d be nicer wrapped in a plugin with Admin string adding, and I may recode your other if and when I have some time. During a long, dark winter night, probably. Anyway, useful code, and thanks again.

    @lincme – create a new topic in that plugin group with the error message and steps taken? (and if you had any certain types blocked prior) – i’m unable to reproduce with a type of ( created_group or nothing)

    the only thing i see at the last step in the group steps is recording the activity, prior to redirect to the group homepage.

    @lincme.co.uk
    Thanks, it’s exactly what I’was looking for. But I want to filter activity only for groups activity, not for global activity. Do you know how I can do this ?

    Guillaume.


    imjscn
    Participant

    @imjscn

    Seems this code not working on my site at all.
    I also tried another way– hide all activity type with “mini” class by modifying the $nothanks like this:

    `$nothanks = bp_get_activity_css_class();`
    and
    `if ($nothanks=’mini’) `

    It does’t work either.
    Any idea?


    gregfielding
    Participant

    @gregfielding

    Bringing this back…Rich’s plugin doesn’t work anymore. I would use the snip above, but I’m not sure where to find the correct functions in this line:
    $nothanks = array(“new_blog_post”, “created_group”, “joined_group”, “new_member”, “friendship_created”, “activity_liked”);

    I would like to filter OUT new follows (bp-follow plugin), new members, and location updates (mapology).

    Any ideas? Thanks!


    Marcos Nobre
    Participant

    @onyx808

    have you tried something like this?

    function filtering_activity_default( $qs ) {
    if ( empty( $qs ) && empty( $_POST ) ) {
    $qs = ‘action=activity_update’;
    }

    return $qs;
    }
    add_filter( ‘bp_ajax_querystring’, ‘filtering_activity_default’, 999 );

    in the functions.php of your theme… this filters everything and only outputs the activity updates


    gregfielding
    Participant

    @gregfielding

    Ok then, I’d also need to add in blog posts and external blog posts (separate plugin)…

    @onyx808: would your code work for my situation? I want to display ONLY profile updates (stuff posted to the “What’s new, x?” text area) on my sitewide activity page, but I want members individual feeds to continue to display everything (profile updates, blog posts, joins, etc.)


    Marcos Nobre
    Participant

    @onyx808

    @justbishop if you put it in the fuctions.php it will filter sitewide… so I guess you will have to put it in the activity loop…

    @onyx808 thanks, got it! Is there anything I can add to it to make it display only the ONE latest update?


    Marcos Nobre
    Participant

    @onyx808

    @justbishop the one lastest update where? in the activity or profile pages?

    Well, I’m trying to show sitewide profile updates only, on my site’s index page, but I only want one. Here’s the code I have on my index page template now:

    http://pastebin.com/stk1pQvd

    Also, if anyone knows how to collapse replies to activity stream entries, I’d welcome that info too :)

    hi i need to filter out all accept for what new members post in ‘whats new’ too but
    im a total nubie to code, would anyone be kind enough to spare a few moments explaining where exactly to place the code in cpanel

    many thanx ;)

    @onyx808

    will my members still be able to ‘reply’ to the activity updates as normal if I insert this code..?

    `function filtering_activity_default( $qs ) {
    if ( empty( $qs ) && empty( $_POST ) ) {
    $qs = ‘action=activity_update’;
    }

    return $qs;
    }
    add_filter( ‘bp_ajax_querystring’, ‘filtering_activity_default’, 999 );`

    Also where exactly do I place this in: functions.php please..?

    ok I’ve placed the above code in activity-loop.php and it looks to saving me the trouble of manually deleting new member registrations group joining etc which is great! but does not block any posts made to my groups unfortunately (beggars can’t be choosers lol)

    I guess I’ll have to look into other areas to prevent group posts from showing up in the activity stream, any guidance would be most helpful !!

    just noticed that my activity stream is now repeating itself after clicking on ‘load more’ and displaying the first page of post updates !!

    maybe the above code isn’t nested properly..?

    would someone be kind enough to hit me up with a possible cause please.

    Also some of the activity notifications are still filtering through for example group joining/friend adding etc again after clicking on the load more button..?


    Tori
    Participant

    @satoriassecret

    @onyx808 you’re a life saver! That code works perfectly.

Viewing 19 replies - 1 through 19 (of 19 total)
  • The topic ‘Filtering out Activity Stream stuff’ is closed to new replies.
Skip to toolbar