bp_get_attachment_document_id( integer $attachment_id )

Get document id for the attachment.

Description

Parameters

$attachment_id

(Required) Attachment ID.

Return

(array|bool)

Source

File: bp-document/bp-document-functions.php

3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
function bp_get_attachment_document_id( $attachment_id = 0 ) {
    global $bp, $wpdb;
 
    if ( ! $attachment_id ) {
        return false;
    }
 
    // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery
    $attachment_document_id = (int) $wpdb->get_var( "SELECT DISTINCT d.id FROM {$bp->document->table_name} d WHERE d.attachment_id = {$attachment_id}" );
 
    return $attachment_document_id;
}

Changelog

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