bbp_get_user_forum_subscriptions

Get a user's subscribed forums.

Description

(array|bool) bbp_get_user_forum_subscriptions( (int) $user_id = 0 ); 

Returns (array|bool)

Results if user has subscriptions, otherwise false

Parameters (1)

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

Usage

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

Defined (1)

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

/includes/users/functions.php  
  1. function bbp_get_user_forum_subscriptions( $user_id = 0 ) { 
  2.  
  3. // Default to the displayed user 
  4. $user_id = bbp_get_user_id( $user_id ); 
  5. if ( empty( $user_id ) ) { 
  6. return false; 
  7.  
  8. // If user has subscriptions, load them 
  9. $subscriptions = bbp_get_user_subscribed_forum_ids( $user_id ); 
  10. if ( !empty( $subscriptions ) ) { 
  11. $query = bbp_has_forums( array( 'post__in' => $subscriptions ) ); 
  12. } else { 
  13. $query = false; 
  14.  
  15. return apply_filters( 'bbp_get_user_forum_subscriptions', $query, $user_id );