bp_document_get_root_parent_id( $child_id )
Return root parent of the given child folder.
Description
Parameters
- $child_id
-
(Required)
Return
(string|null)
Source
File: bp-document/bp-document-functions.php
function bp_document_get_root_parent_id( $child_id ) {
global $bp, $wpdb;
$table = $bp->document->table_name_folder;
$parent_id = $wpdb->get_var(
$wpdb->prepare(
"SELECT f.id
FROM (
SELECT @id AS _id, (SELECT @id := parent FROM {$table} WHERE id = _id)
FROM (SELECT @id := %d) tmp1
JOIN {$table} ON @id <> 0
) tmp2
JOIN {$table} f ON tmp2._id = f.id
WHERE f.parent = 0",
$child_id
)
);
return $parent_id;
}
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.