bp_attachments_delete_file

Delete an attachment for the given arguments.

Description

bp_attachments_delete_file( (array) $args = array() ); 

Parameters (1)

0. $args — Optional. (array) => array()
Array of arguments for the attachment deletion.

Usage

  1. if ( !function_exists( 'bp_attachments_delete_file' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-attachments.php'; 
  3.  
  4. // Array of arguments for the attachment deletion. 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_attachments_delete_file($args); 
  9.  

Defined (1)

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

/bp-core/bp-core-attachments.php  
  1. function bp_attachments_delete_file( $args = array() ) { 
  2. $attachment_path = bp_attachments_get_attachment( 'path', $args ); 
  3.  
  4. /** 
  5. * Filters whether or not to handle deleting an existing BuddyPress attachment. 
  6. * If you want to override this function, make sure you return false. 
  7. * @since 2.5.1 
  8. * @param bool $value Whether or not to delete the BuddyPress attachment. 
  9. ` * @param array $args Array of arguments for the attachment deletion. 
  10. */ 
  11. if ( ! apply_filters( 'bp_attachments_pre_delete_file', true, $args ) ) { 
  12. return true; 
  13.  
  14. if ( empty( $attachment_path ) ) { 
  15. return false; 
  16.  
  17. @unlink( $attachment_path ); 
  18. return true;