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

3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
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

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.