bbp_get_subscriptions_permalink( int $user_id )
Return the link to the user’s subscriptions page (profile page)
Description Description
Parameters Parameters
- $user_id
-
(Optional) User id
Return Return
(string) Permanent link to user subscriptions page
Source Source
File: includes/users/template.php
function bbp_get_subscriptions_permalink( $user_id = 0 ) {
// 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;
}
// Bail if intercepted
$intercept = bbp_maybe_intercept( 'bbp_pre_get_subscriptions_permalink', func_get_args() );
if ( bbp_is_intercepted( $intercept ) ) {
return $intercept;
}
// Get user profile URL
$profile_url = bbp_get_user_profile_url( $user_id );
$page = 0;
$paged = false;
// Get pagination data
if ( bbpress()->topic_query->in_the_loop ) {
$page = (int) bbpress()->topic_query->paged;
$paged = (bool) bbpress()->topic_query->in_the_loop;
} elseif ( bbpress()->forum_query->in_the_loop ) {
$page = (int) bbpress()->forum_query->paged;
$paged = (bool) bbpress()->forum_query->in_the_loop;
}
// Pretty permalinks
if ( bbp_use_pretty_urls() ) {
// Base URL
$url = trailingslashit( $profile_url ) . bbp_get_user_subscriptions_slug();
// Add page
if ( ( true === $paged ) && ( $page > 1 ) ) {
$url = trailingslashit( $url ) . bbp_get_paged_slug() . '/' . $page;
}
// Ensure correct trailing slash
$url = user_trailingslashit( $url );
// Unpretty permalinks
} else {
// Base arguments
$args = array(
bbp_get_user_subscriptions_rewrite_id() => bbp_get_user_subscriptions_slug(),
);
// Add page
if ( ( true === $paged ) && ( $page > 1 ) ) {
$args['page'] = $page;
}
// Add arguments
$url = add_query_arg( $args, $profile_url );
}
// Filter & return
return apply_filters( 'bbp_get_subscriptions_permalink', $url, $user_id );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | bbPress (r6308) Add pagination if in the loop |
| 2.0.0 | Introduced. |