bp_activity_delete_children

Delete an activity comment's children.

Description

bp_activity_delete_children( (int) $activity_id, (int) $comment_id ); 

Parameters (2)

0. $activity_id (int)
The ID of the root activity, ie the comment's oldest ancestor.
1. $comment_id (int)
The ID of the comment to be deleted.

Usage

  1. if ( !function_exists( 'bp_activity_delete_children' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // The ID of the "root" activity, ie the 
  5. // comment's oldest ancestor. 
  6. $activity_id = -1; 
  7.  
  8. // The ID of the comment to be deleted. 
  9. $comment_id = -1; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_activity_delete_children($activity_id, $comment_id); 
  13.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_delete_children( $activity_id, $comment_id ) { 
  2.  
  3. // Get activity children to delete. 
  4. $children = BP_Activity_Activity::get_child_comments( $comment_id ); 
  5.  
  6. // Recursively delete all children of this comment. 
  7. if ( ! empty( $children ) ) { 
  8. foreach( (array) $children as $child ) { 
  9. bp_activity_delete_children( $activity_id, $child->id ); 
  10.  
  11. // Delete the comment itself. 
  12. 'secondary_item_id' => $comment_id,  
  13. 'type' => 'activity_comment',  
  14. 'item_id' => $activity_id 
  15. ) );