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

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.