bp_dtheme_delete_activity

Deletes an Activity item received via a POST request.

Description

bp_dtheme_delete_activity(); 

Usage

  1. if ( !function_exists( 'bp_dtheme_delete_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-themes/bp-default/_inc/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_dtheme_delete_activity(); 
  7.  

Defined (1)

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

/bp-themes/bp-default/_inc/ajax.php  
  1. function bp_dtheme_delete_activity() { 
  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 ( ! is_user_logged_in() ) 
  10. exit( '-1' ); 
  11.  
  12. if ( empty( $_POST['id'] ) || ! is_numeric( $_POST['id'] ) ) 
  13. exit( '-1' ); 
  14.  
  15. $activity = new BP_Activity_Activity( (int) $_POST['id'] ); 
  16.  
  17. // Check access 
  18. if ( ! bp_activity_user_can_delete( $activity ) ) 
  19. exit( '-1' ); 
  20.  
  21. // Call the action before the delete so plugins can still fetch information about it 
  22. do_action( 'bp_activity_before_action_delete_activity', $activity->id, $activity->user_id ); 
  23.  
  24. if ( ! bp_activity_delete( array( 'id' => $activity->id, 'user_id' => $activity->user_id ) ) ) 
  25. exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem when deleting. Please try again.', buddypress ) . '</p></div>' ); 
  26.  
  27. do_action( 'bp_activity_action_delete_activity', $activity->id, $activity->user_id ); 
  28. exit;