BP_Activity_Activity::append_comments( array $activities, string $spam = 'ham_only' )

Append activity comments to their associated activity items.

Description

Parameters

$activities

(Required) Activities to fetch comments for.

$spam

(Optional) 'ham_only' (default), 'spam_only' or 'all'.

Default value: 'ham_only'

Return

(array) The updated activities with nested comments.

Source

File: bp-activity/classes/class-bp-activity-activity.php

1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
public static function append_comments( $activities, $spam = 'ham_only' ) {
    $activity_comments = array();
 
    // Now fetch the activity comments and parse them into the correct position in the activities array.
    foreach ( (array) $activities as $activity ) {
        $top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0;
        $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );
    }
 
    // Merge the comments with the activity items.
    foreach ( (array) $activities as $key => $activity ) {
        if ( isset( $activity_comments[$activity->id] ) ) {
            $activities[$key]->children = $activity_comments[$activity->id];
        }
    }
 
    return $activities;
}

Changelog

Changelog
Version Description
BuddyPress 1.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.