bp_legacy_theme_delete_activity_comment

Deletes an Activity comment received via a POST request.

Description

bp_legacy_theme_delete_activity_comment(); 

Usage

  1. if ( !function_exists( 'bp_legacy_theme_delete_activity_comment' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-templates/bp-legacy/buddypress-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_legacy_theme_delete_activity_comment(); 
  7.  

Defined (1)

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

/bp-templates/bp-legacy/buddypress-functions.php  
  1. function bp_legacy_theme_delete_activity_comment() { 
  2. // Bail if not a POST action. 
  3. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 
  4. return; 
  5.  
  6. // Check the nonce. 
  7. check_admin_referer( 'bp_activity_delete_link' ); 
  8.  
  9. if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) { 
  10. exit( '-1' ); 
  11.  
  12. if ( ! is_user_logged_in() ) { 
  13. exit( '-1' ); 
  14.  
  15. $comment = new BP_Activity_Activity( $_POST['id'] ); 
  16.  
  17. // Check access. 
  18. if ( ! bp_current_user_can( 'bp_moderate' ) && $comment->user_id != bp_loggedin_user_id() ) 
  19. exit( '-1' ); 
  20.  
  21. /** This action is documented in bp-activity/bp-activity-actions.php */ 
  22. do_action( 'bp_activity_before_action_delete_activity', $_POST['id'], $comment->user_id ); 
  23.  
  24. if ( ! bp_activity_delete_comment( $comment->item_id, $comment->id ) ) 
  25. exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'There was a problem when deleting. Please try again.', buddypress ) . '</p></div>' ); 
  26.  
  27. /** This action is documented in bp-activity/bp-activity-actions.php */ 
  28. do_action( 'bp_activity_action_delete_activity', $_POST['id'], $comment->user_id ); 
  29. exit;