Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding “[User] joined the group [GroupName]” from group feeds without editing core files?

  • I’ve got group feeds being sent to Twitter and I don’t want “[User] joined the group [Group Name]” messages to appear. The code that creates these feeds is located in `/wp-content/plugins/buddypress/bp-activity/feeds/bp-activity-group-feed.php`.

    I figured I could use `preg_match` with `bp_get_activity_feed_item_title()` to selectively filter the output, but since there doesn’t seem to be any hooks I can use, what would be the best way to implement this without editing any core files?

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is what I’ve got so far, but it’s not working…

    `function nla_bp_has_activities($val){
    global $activities_template;$i=0;$a=array();
    //var_dump($activities_template);exit();
    foreach($activities_template->activities as $item){
    if($item->type == “joined_group”)
    $a[]=$i;
    $i++;
    }
    foreach($a as $item)unset($activities_template->activities[$item]);
    array_values($activities_template->activities);
    $activities_template->activity_count=count($activities_template->activities);
    $activities_template->total_activity_count=count($activities_template->activities);
    //var_dump($activities_template);exit();
    return $val;
    }
    add_action( ‘bp_has_activities’,’nla_bp_has_activities’ );`

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    There’s a plugin for this:
    http://wordpress.org/extend/plugins/buddypress-block-activity-stream-types/

    It’s an older plugin and the developer is now busy with other projects, so you’ll need to update the plugin manually so the admin menu will show up in WP.

    Read this tutorial:
    http://code.ipstenu.org/2011/wordpress-3-1-network-menu/

    (Edit) Just read the full post, you want to hide it from group feeds only? Or throughout the site? If throughout the site, the plugin will do the job. If only on group feeds, you can take the basic premise from the plugin, then you’ll need to do a conditional to check if you’re in a BP feed.

    That plugin you mentioned appears to prevent saving of certain activity types. Since I still want “user joined the group” messages to appear on non-feed pages, that plugin doesn’t really help.

    In the end I came up with this code, which appears to work well so far:

    `function nla_bp_has_activities( $val )
    {
    if( ! is_feed() )
    return $val;
    global $activities_template;
    $i=0;
    foreach( $activities_template->activities as $item )
    {
    if( $item->type == “joined_group” )
    $joined[] = $i;
    $i++;
    }
    foreach( $joined as $item )
    unset( $activities_template->activities[$item] );
    foreach( $activities_template->activities as $item )
    $activities[] = $item;
    $activities_template->activities = $activities;
    $activities_template->activity_count = count( $activities_template->activities );
    $activities_template->total_activity_count = count( $activities_template->activities );
    $GLOBALS = $activities_template;
    return $val;
    }
    add_action( ‘bp_has_activities’, ‘nla_bp_has_activities’ );`

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

You must be logged in to reply to this topic.