bp_activity_delete_children( int $activity_id, int $comment_id )

Delete an activity comment’s children.


Description Description


Parameters Parameters

$activity_id

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

$comment_id

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


Top ↑

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

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.