bbp_get_reply_ancestor_id( in $reply_id )

Return the reply’s ancestor reply id

Description

Parameters

$reply_id

(Required) Reply id

Source

File: bp-forums/replies/template.php

1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
 
    // Validation
    $reply_id = bbp_get_reply_id( $reply_id );
    if ( empty( $reply_id ) )
        return false;
 
    // Find highest reply ancestor
    $ancestor_id = $reply_id;
    while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) {
        if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) {
            break;
        }
        $ancestor_id = $parent_id;
    }
 
    return (int) $ancestor_id;
}

Changelog

Changelog
Version Description
bbPress (r4944) 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.