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
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
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.