bbp_get_subscriptions_permalink( int $user_id )

Return the link to the user’s subscriptions page (profile page)

Description

Parameters

$user_id

(Optional) User id

Return

(string) Permanent link to user subscriptions page

Source

File: bp-forums/users/template.php

996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
function bbp_get_subscriptions_permalink( $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_profile_url = apply_filters( 'bbp_pre_get_subscriptions_permalink', (int) $user_id );
    if ( is_string( $early_profile_url ) )
        return $early_profile_url;
 
    // Pretty permalinks
    if ( $wp_rewrite->using_permalinks() ) {
        $url  = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/%' . bbp_get_user_subscriptions_rewrite_id() . '%';
        $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 = str_replace( '%' . bbp_get_user_subscriptions_rewrite_id() . '%', bbp_get_user_subscriptions_slug(), $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_subscriptions_rewrite_id() => bbp_get_user_subscriptions_slug(),
        ), home_url( '/' ) );
    }
 
    return apply_filters( 'bbp_get_subscriptions_permalink', $url, $user_id );
}

Changelog

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