bp_attachments_delete_file( array $args = array() )

Delete an attachment for the given arguments

Description

See also

Parameters

$args

(array) (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

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

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.