bbp_get_user_topics_created_url( int $user_id )

Return the link to the user’s topics

Description

Parameters

$user_id

(Optional) User id

Return

(string) Permanent link to user profile page

Source

File: bp-forums/users/template.php

1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
function bbp_get_user_topics_created_url( $user_id = 0 ) {
    global $wp_rewrite;
 
    // Use displayed user ID if there is one, and one isn't requested
    $user_id = bbp_get_user_id( $user_id );
    if ( empty( $user_id ) )
        return false;
 
    // Allow early overriding of the profile URL to cut down on processing
    $early_url = apply_filters( 'bbp_pre_get_user_topics_created_url', (int) $user_id );
    if ( is_string( $early_url ) )
        return $early_url;
 
    // Pretty permalinks
    if ( $wp_rewrite->using_permalinks() ) {
        $url  = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/' . bbp_get_topic_archive_slug();
        $user = get_userdata( $user_id );
        if ( ! empty( $user->user_nicename ) ) {
            $user_nicename = $user->user_nicename;
        } else {
            $user_nicename = $user->user_login;
        }
        $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url );
        $url = home_url( user_trailingslashit( $url ) );
 
    // Unpretty permalinks
    } else {
        $url = add_query_arg( array(
            bbp_get_user_rewrite_id()        => $user_id,
            bbp_get_user_topics_rewrite_id() => '1',
        ), home_url( '/' ) );
    }
 
    return apply_filters( 'bbp_get_user_topics_created_url', $url, $user_id );
}

Changelog

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