bp_activity_delete_children( int $activity_id, int $comment_id )

Delete an activity comment’s children.

Description

Parameters

$activity_id

(int) (Required) The ID of the "root" activity, ie the comment's oldest ancestor.

$comment_id

(int) (Required) The ID of the comment to be deleted.

Source

File: bp-activity/bp-activity-functions.php

	function bp_activity_delete_children( $activity_id, $comment_id ) {
		// Check if comment still exists.
		$comment = new BP_Activity_Activity( $comment_id );
		if ( empty( $comment->id ) ) {
			return;
		}

		// Get activity children to delete.
		$children = BP_Activity_Activity::get_child_comments( $comment_id );

		// Recursively delete all children of this comment.
		if ( ! empty( $children ) ) {
			foreach( (array) $children as $child ) {
				bp_activity_delete_children( $activity_id, $child->id );
			}
		}

		// Delete the comment itself.
		bp_activity_delete( array(
			'secondary_item_id' => $comment_id,
			'type'              => 'activity_comment',
			'item_id'           => $activity_id
		) );
	}

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.