bp_nouveau_ajax_document_delete_attachment()
Delete attachment with its files
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
function bp_nouveau_ajax_document_delete_attachment() {
$response = array(
'feedback' => sprintf(
'<div class="bp-feedback bp-messages error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
esc_html__( 'There was a problem displaying the content. Please try again.', 'buddyboss' )
),
);
// Nonce check!
$nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING );
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'bp_nouveau_media' ) ) {
wp_send_json_error( $response );
}
if ( empty( $_POST['id'] ) ) {
$response['feedback'] = sprintf(
'<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>',
esc_html__( 'Please provide attachment id to delete.', 'buddyboss' )
);
wp_send_json_error( $response );
}
// delete attachment with its meta.
$post_id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT );
$deleted = wp_delete_attachment( $post_id, true );
if ( ! $deleted ) {
wp_send_json_error( $response );
}
wp_send_json_success();
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.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.