bp_attachments_delete_file( array $args = array() )
Delete an attachment for the given arguments
Description
See also
- bp_attachments_get_attachment(): For more information on accepted arguments.
Parameters
- $args
-
(Optional) Array of arguments for the attachment deletion.
Default value: array()
Return
(bool) True if the attachment was deleted, false otherwise.
Source
File: bp-core/bp-core-attachments.php
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | function bp_attachments_delete_file( $args = array () ) { $attachment_path = bp_attachments_get_attachment( 'path' , $args ); /** * Filters whether or not to handle deleting an existing BuddyPress attachment. * * If you want to override this function, make sure you return false. * * @since BuddyPress 2.5.1 * * @param bool $value Whether or not to delete the BuddyPress attachment. ` * @param array $args Array of arguments for the attachment deletion. */ if ( ! apply_filters( 'bp_attachments_pre_delete_file' , true, $args ) ) { return true; } if ( empty ( $attachment_path ) ) { return false; } @unlink( $attachment_path ); return true; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.