Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Filtering out Activity Stream stuff (19 posts)

Started 1 year, 10 months ago by: lincme.co.uk

  • Profile picture of lincme.co.uk lincme.co.uk said 1 year, 10 months ago:

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

  • Profile picture of rich! @ etiviti rich! @ etiviti said 1 year, 10 months ago:

    if a site owner does not care about certain activity items at all – block em:

    http://wordpress.org/extend/plugins/buddypress-block-activity-stream-types/

  • Profile picture of lincme.co.uk lincme.co.uk said 1 year, 10 months ago:

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

  • Profile picture of rich! @ etiviti rich! @ etiviti said 1 year, 10 months ago:

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

  • Profile picture of guigoz guigoz said 1 year, 10 months ago:

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

  • Profile picture of imjscn imjscn said 1 year, 3 months ago:

    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?

  • Profile picture of gregfielding gregfielding said 11 months, 3 weeks ago:

    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!

  • Profile picture of onyx808 onyx808 said 11 months, 3 weeks ago:

    have you tried something like this?

    function filtering_activity_default( $qs ) {
    if ( empty( $qs ) && empty( $_POST['action'] ) ) {
    $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

  • Profile picture of gregfielding gregfielding said 11 months, 3 weeks ago:

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

  • Profile picture of justbishop justbishop said 11 months, 2 weeks ago:

    @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.)

  • Profile picture of onyx808 onyx808 said 11 months, 2 weeks ago:

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

  • Profile picture of justbishop justbishop said 11 months, 2 weeks ago:

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

  • Profile picture of onyx808 onyx808 said 11 months, 2 weeks ago:

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

  • Profile picture of justbishop justbishop said 11 months, 2 weeks ago:

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

  • Profile picture of justbishop justbishop said 11 months, 2 weeks ago:

    Nevermind, I think I found my answers :)

    http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/