bp_attachments_delete_file( array $args = array() )

Delete an attachment for the given arguments


Description Description

See also See also


Top ↑

Parameters Parameters

$args

(Optional) Array of arguments for the attachment deletion.

Default value: array()


Top ↑

Return Return

(bool) True if the attachment was deleted, false otherwise.


Top ↑

Source 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 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;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.