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