bp_media_delete_attachment_media( int $attachment_id )

Delete media entries attached to the attachment

Description

Parameters

$attachment_id

(Required) ID of the attachment being deleted.

Source

File: bp-media/bp-media-filters.php

1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
function bp_media_delete_attachment_media( $attachment_id ) {
    global $wpdb;
 
    $bp = buddypress();
 
    $media = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->media->table_name} WHERE attachment_id = %d", $attachment_id ) );
 
    if ( ! $media ) {
        return false;
    }
 
    remove_action( 'delete_attachment', 'bp_media_delete_attachment_media', 0 );
 
    bp_media_delete( array( 'id' => $media->id ), 'attachment' );
 
    add_action( 'delete_attachment', 'bp_media_delete_attachment_media', 0 );
}

Changelog

Changelog
Version Description
BuddyBoss 1.2.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.