bb_get_forum
The BuddyPress bb get forum function.
Description
bb_get_forum( $id );
Parameters (1)
- 0. $id
- The id.
Usage
if ( !function_exists( 'bb_get_forum' ) ) { require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-forums.php'; } // The id. $id = null; // NOTICE! Understand what this does before running. $result = bb_get_forum($id);
Defined (1)
The function is defined in the following location(s).
- /bp-forums/bbpress/bb-includes/functions.bb-forums.php
- function bb_get_forum( $id ) {
- global $bbdb;
- if ( !is_numeric($id) ) {
- list($slug, $sql) = bb_get_sql_from_slug( 'forum', $id );
- $id = wp_cache_get( $slug, 'bb_forum_slug' );
- }
- // not else
- if ( is_numeric($id) )
- $sql = $bbdb->prepare( "forum_id = %d", $id );
- if ( 0 === $id || empty( $sql ) )
- return false;
- // $where is NOT bbdb:prepared
- if ( $where = apply_filters( 'get_forum_where', '' ) ) {
- $forum = $bbdb->get_row( "SELECT * FROM $bbdb->forums WHERE $sql $where" );
- return bb_append_meta( $forum, 'forum' );
- }
- if ( is_numeric($id) && false !== $forum = wp_cache_get( $id, 'bb_forum' ) )
- return $forum;
- $forum = $bbdb->get_row( "SELECT * FROM $bbdb->forums WHERE $sql" );
- $forum = bb_append_meta( $forum, 'forum' );
- wp_cache_set( $forum->forum_id, $forum, 'bb_forum' );
- wp_cache_add( $forum->forum_slug, $forum->forum_id, 'bb_forum_slug' );
- return $forum;
- }