bb_get_forum

The BuddyPress bb get forum function.

Description

bb_get_forum( $id ); 

Parameters (1)

0. $id
The id.

Usage

  1. if ( !function_exists( 'bb_get_forum' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-forums.php'; 
  3.  
  4. // The id. 
  5. $id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_forum($id); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-forums.php  
  1. function bb_get_forum( $id ) { 
  2. global $bbdb; 
  3.  
  4. if ( !is_numeric($id) ) { 
  5. list($slug, $sql) = bb_get_sql_from_slug( 'forum', $id ); 
  6. $id = wp_cache_get( $slug, 'bb_forum_slug' ); 
  7.  
  8. // not else 
  9. if ( is_numeric($id) ) 
  10. $sql = $bbdb->prepare( "forum_id = %d", $id ); 
  11.  
  12. if ( 0 === $id || empty( $sql ) ) 
  13. return false; 
  14.  
  15. // $where is NOT bbdb:prepared 
  16. if ( $where = apply_filters( 'get_forum_where', '' ) ) { 
  17. $forum = $bbdb->get_row( "SELECT * FROM $bbdb->forums WHERE $sql $where" ); 
  18. return bb_append_meta( $forum, 'forum' ); 
  19.  
  20. if ( is_numeric($id) && false !== $forum = wp_cache_get( $id, 'bb_forum' ) ) 
  21. return $forum; 
  22.  
  23. $forum = $bbdb->get_row( "SELECT * FROM $bbdb->forums WHERE $sql" ); 
  24. $forum = bb_append_meta( $forum, 'forum' ); 
  25. wp_cache_set( $forum->forum_id, $forum, 'bb_forum' ); 
  26. wp_cache_add( $forum->forum_slug, $forum->forum_id, 'bb_forum_slug' ); 
  27.  
  28. return $forum;