Skip to:
Content
Pages
Categories
Search
Top
Bottom

Please help with activity comments

  • @humiges

    Participant

    Hello,

    Please, when users post a reply to a comment on buddypress group…. his profile activity is missing links to where he/she made a comment… so it looks like this:

    Mike posted a new activity comment
    the actual comment

    Is there any way, I can change the activity to

    Mike posted a new comment on GROUP-NAME
    the actual comment

    So, user can actually click on Group-name ???

    I know there is solution to remove ALL of the activity_comment from the activity completely, but we don’t want to do that. ( https://buddypress.org/support/topic/i-am-trying-to-remove-activity-comments-as-separate-entries/ )

    Bizarrely, this problem isn’t on all users activity page.

    Thank you very much

Viewing 3 replies - 1 through 3 (of 3 total)
  • @sbrajesh

    Participant

    Hi,
    Please put the following code to your bp-custom.php

    
    
    /**
     * Step 1: Store the group id in meta when there is a new comment.
     */
    function buddydev_store_group_in_activity_meta( $comment_id, $r, $activity ) {
    
    	if ( $activity->component != 'groups' ) {
    		return;
    	}
    
    	bp_activity_update_meta( $comment_id, '_group_id', $activity->item_id );
    }
    
    // hook to comment posted action
    add_action( 'bp_activity_comment_posted', 'buddydev_store_group_in_activity_meta', 10, 3 );
    add_action( 'bp_activity_comment_posted_notification_skipped', 'buddydev_store_group_in_activity_meta', 10, 3 );
    
    //Filter the action string for comment and display it.
    function buddydev_add_group_link_in_activity_comment_action( $action, $activity ) {
    
    	$group_id = bp_activity_get_meta( $activity->id, '_group_id', true );
    
    	if ( ! $group_id ) {
    		return $action;
    	}
    
    	$group = new BP_Groups_Group( $group_id );
    
    	if ( ! $group->id ) {
    		return $action;
    	}
    
    	$action = $action . sprintf( " in group <a href='%s'>%s</a>", bp_get_group_permalink( $group ), bp_get_group_name( $group ) );
    
    	return $action;
    }
    add_filter( 'bp_activity_comment_action', 'buddydev_add_group_link_in_activity_comment_action', 10, 2 );
    
    

    It records the group id in activity meta and uses that for displaying the group link.

    Please do note that it will only work for newer comments.

    Hope that helps.

    @humiges

    Participant

    WOW!
    I can’t possibly express how grateful I’m!
    I have been looking for this for ages… this issue is one of the most illogical thing of otherwise quite awesome BuddyPress!

    Thank you SOOOOOO much :)))

    @humiges

    Participant

    Dear @sbrajesh
    Sorry to bother you.
    Please, is there any chance you know how to remove this activity from Buddypress profile?

    Mike “posted a new activity comment”

    This is without url to the actual blog post so it’s useless. I tried to remove it from bp-activity-functions but it actually removes even the posted a new activity comment in a group.

    Thanks a lot:)

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar