bbp_get_subscriptions_permalink

Return the link to the user's subscriptions page (profile page).

Description

(string) bbp_get_subscriptions_permalink( (int) $user_id = 0 ); 

Returns (string)

Permanent link to user subscriptions page

Parameters (1)

0. $user_id — Optional. (int)
User id

Usage

  1. if ( !function_exists( 'bbp_get_subscriptions_permalink' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/template.php'; 
  3.  
  4. // Optional. User id 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_subscriptions_permalink($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/users/template.php  
  1. function bbp_get_subscriptions_permalink( $user_id = 0 ) { 
  2. global $wp_rewrite; 
  3.  
  4. // Use displayed user ID if there is one, and one isn't requested 
  5. $user_id = bbp_get_user_id( $user_id ); 
  6. if ( empty( $user_id ) ) 
  7. return false; 
  8.  
  9. // Allow early overriding of the profile URL to cut down on processing 
  10. $early_profile_url = apply_filters( 'bbp_pre_get_subscriptions_permalink', (int) $user_id ); 
  11. if ( is_string( $early_profile_url ) ) 
  12. return $early_profile_url; 
  13.  
  14. // Pretty permalinks 
  15. if ( $wp_rewrite->using_permalinks() ) { 
  16. $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/%' . bbp_get_user_subscriptions_rewrite_id() . '%'; 
  17. $user = get_userdata( $user_id ); 
  18. if ( ! empty( $user->user_nicename ) ) { 
  19. $user_nicename = $user->user_nicename; 
  20. } else { 
  21. $user_nicename = $user->user_login; 
  22. $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 
  23. $url = str_replace( '%' . bbp_get_user_subscriptions_rewrite_id() . '%', bbp_get_user_subscriptions_slug(), $url ); 
  24. $url = home_url( user_trailingslashit( $url ) ); 
  25.  
  26. // Unpretty permalinks 
  27. } else { 
  28. $url = add_query_arg( array( 
  29. bbp_get_user_rewrite_id() => $user_id,  
  30. ), home_url( '/' ) ); 
  31.  
  32. return apply_filters( 'bbp_get_subscriptions_permalink', $url, $user_id );