bbp_get_topic_author_display_name( int $topic_id )

Return the author display_name of the topic

Description

Parameters

$topic_id

(Optional) Topic id

Return

(string) Topic's author's display name

Source

File: bp-forums/topics/template.php

1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
function bbp_get_topic_author_display_name( $topic_id = 0 ) {
    $topic_id = bbp_get_topic_id( $topic_id );
 
    // Check for anonymous user
    if ( !bbp_is_topic_anonymous( $topic_id ) ) {
 
        // Get the author ID
        $author_id = bbp_get_topic_author_id( $topic_id );
 
        // Try to get a display name
        $author_name = get_the_author_meta( 'display_name', $author_id );
 
        // Fall back to user login
        if ( empty( $author_name ) ) {
            $author_name = get_the_author_meta( 'user_login', $author_id );
        }
 
    // User does not have an account
    } else {
        $author_name = get_post_meta( $topic_id, '_bbp_anonymous_name', true );
    }
 
    // If nothing could be found anywhere, use Anonymous
    if ( empty( $author_name ) )
        $author_name = __( 'Anonymous', 'buddyboss' );
 
    // Encode possible UTF8 display names
    if ( seems_utf8( $author_name ) === false )
        $author_name = utf8_encode( $author_name );
 
    return apply_filters( 'bbp_get_topic_author_display_name', $author_name, $topic_id );
}

Changelog

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