Skip to:
Content
Pages
Categories
Search
Top
Bottom

I am trying to remove activity comments as separate entries


  • browserco
    Participant

    @browserco

    Hi everyone, I would like to remove the function that forces activity comments to show as separate entries. It is filling up my activity stream and overshadowing my activity posts. Commenting on another user’s activity post is the core feature of my network, but I think comments should stay where they are posted. I have unchecked the options in BuddyPress settings page to not allow comments from blog post and forum. Also it is not good for privacy as anyone can see all of another user’s comments and replies on their activity feed while viewing that user’s profile. I am using the BP Activity Privacy plugin but it has no affect on comments and replies.

    I am not good with coding but have come up with this code to attempt to remove it:
    // Stop activity loops from showing activity comments as separate entries

    function remove_comment_replies() {
    remove_filter( ‘bp_after_has_activities_parse_args’, ‘ray_bp_display_comments_stream’, 20 );

    add_action( ‘bp_after_has_activities_parse_args’, ‘remove_comment_replies’ );

    It doesn’t work. Any suggestions would be very much appreciated (see link to better understand what I am referring to.) Thank you.

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

  • browserco
    Participant

    @browserco

    Also, I think the link is a plugin. But I read in another topic that it was added to the buddypress core. Anyway, I have no clue and I will be grateful for any help in this regard.


    danbp
    Moderator

    @danbp

    Create first a bp-custom.php file and add it to the plugins directory.

    Than add these snippet, which let you handle activities which may not be commented.

    function browserco_activity_nocomment( $can_comment = true, $type = '' ) {
            if ( empty( $can_comment ) ) {
                    return $can_comment;
            }
    		
            // list of activities which can't be commented
            $cant_comment_types = array( 
    				'new_forum_topic' => 1,
    				'new_forum_post' => 1,
            );
     
            return ! isset( $cant_comment_types[ $type ] );
    }
    add_filter( 'bp_activity_can_comment', 'browserco_activity_nocomment', 10, 2 );

    Some BP activity types
    activity_comment
    activity_update
    last_activity
    friendship_created
    joined_group
    new_blog_post
    new_avatar
    updated_profile

    Note that some plugins add their own activity types. To get activity type names, go to the DB and check the “type” column in _bp_activity table.


    browserco
    Participant

    @browserco

    I am sorry for double posting. But maybe I didn’t explain correctly what I want to do. I want all activities to allow comments but I don’t want the comments (which says ‘Browserco posted a new activity comment‘) posted to the activity feed.

    For example, when I comment on something Beyonce just posted to her activity stream a copy of my comment also posts to my activity feed along with a ‘view conversation’ button so everyone can see my response to that activity. This becomes a problem when I make a comment on several user’s activity updates because my feed quickly fills up with them such as if I were liking activities across the site all you will notice on my activity feed is ‘Browserco commented…’ or ‘Browserco liked…’ too many times that it overshadows my updates (things I want to share with my friends/followers). I don’t want that. Comments should not be posted by themselves as separate entries, but I think should stay where they are posted (in this case, on Beyonce’s profile under her activity update). That way users activity posts which has its own comment and replies beneath them are not overshadowed on their feed.

    I know this is a very great feature but it is best to be included in the select filter box so users can choose to see another users comments across the site or a user can see/keep track of their own comments across the site without having to go to the original activity.

    I hope I explained myself well enough. Also I found a way to show ‘activity updates only’ in the activity feed so this issue is actually resolved. But I really would like to request that comments from across the site can be filtered via the select box or another tab. It is really nice to see my comments without having to go to actual activity post.

    Thank you


    Steve
    Participant

    @aksteve

    Did you ever figure this out? My client wants the same thing. He does not like that the activity stream is filled with “john is now friends with Amy”, “Amy updated her profile”, “Sam is friends with Peter”.

    Really, who cares.

    Did the above code fix this or is there some other way to get rid of these notifications.

    Thanks.


    browserco
    Participant

    @browserco

    Hi Steve, the code above disallows commenting on specific activity types which is not what I wanted. To get rid of those pesky notifications on the activity stream you should use this code in your theme’s functions.php file:

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

    I got the code from this thread.

    I hope it works out for you!


    danbp
    Moderator

    @danbp

    @browserco,

    thank you for your help, but please, don’t give a 4 years old solution without testing it.
    At first, the snippet contains cote errors, and second, it doesn’t work with BP 2.x, as things has changed.

    You can easily modify your template loop by using bp_parse_args function.

    Here a working example (activity-update is commented – uncomment to see the difference)

    You simply have to list what to show. Anything not listed will be ignored, on all activity feeds.

    Add this to bp-custom.php or child theme functions.php

    function my_bp_activities_include_activity_types( $retval ) {
    // only allow the following activity types to be shown
        $retval['action'] = array(
         //   'activity_update',
            'activity_comment',
            'new_blog_post',
            'new_blog_comment',
            'friendship_created',
            'created_group',
        );
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_include_activity_types' );

    r-a-y
    Keymaster

    @r-a-y

    The simple thing here is to remove all your custom code snippets that are interacting with the activity stream.

    In your original post, I see you’re using this:
    remove_filter( 'bp_after_has_activities_parse_args', 'ray_bp_display_comments_stream', 20 );

    Which means you have a function called ray_bp_display_comments_stream() somewhere which is causing the singular activity comment entries to display.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I am trying to remove activity comments as separate entries’ is closed to new replies.
Skip to toolbar