bbp_get_topic_author_email( int $topic_id )

Return the topic author email address

Description

Parameters

$topic_id

(Optional) Reply id

Return

(string) Topic author email address

Source

File: bp-forums/topics/template.php

1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
function bbp_get_topic_author_email( $topic_id = 0 ) {
    $topic_id = bbp_get_topic_id( $topic_id );
 
    // Not anonymous user
    if ( !bbp_is_topic_anonymous( $topic_id ) ) {
 
        // Use topic author email address
        $user_id      = bbp_get_topic_author_id( $topic_id );
        $user         = get_userdata( $user_id );
        $author_email = !empty( $user->user_email ) ? $user->user_email : '';
 
    // Anonymous
    } else {
 
        // Get email from post meta
        $author_email = get_post_meta( $topic_id, '_bbp_anonymous_email', true );
 
        // Sanity check for missing email address
        if ( empty( $author_email ) ) {
            $author_email = '';
        }
    }
 
    return apply_filters( 'bbp_get_topic_author_email', $author_email, $topic_id );
}

Changelog

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