-
do_action( 'bbpress_init' )
Source Reference:
-
return false; if ( !bp_forums_is_installed_correctly() ) { bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); bp_core_redirect( bp_get_root_domain() ); } bp_update_is_directory( true, 'forums' ); do_action( 'bbpress_init' ); // Check to see if the user has posted a new topic from the forums page. if ( isset( $_POST['submit_topic'] ) && bp_is_active( 'forums' ) ) { check_admin_referer( 'bp_forums_new_topic' ); $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ); if ( !empty( $bp->groups->current_group->id ) ) { // Auto join this user if they are not yet a member of this group if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) groups_join_group( $bp->groups->current_group->id ); -
function bp_forums_has_directory() { global $bp; return (bool) !empty( $bp->pages->forums->id ); } /** Forum Functions ***********************************************************/ function bp_forums_get_forum( $forum_id ) { do_action( 'bbpress_init' ); return bb_get_forum( $forum_id ); } function bp_forums_new_forum( $args = '' ) { do_action( 'bbpress_init' ); $defaults = array( 'forum_name' => '', 'forum_desc' => '', 'forum_parent_id' => bp_forums_parent_forum_id(), -
/** Forum Functions ***********************************************************/ function bp_forums_get_forum( $forum_id ) { do_action( 'bbpress_init' ); return bb_get_forum( $forum_id ); } function bp_forums_new_forum( $args = '' ) { do_action( 'bbpress_init' ); $defaults = array( 'forum_name' => '', 'forum_desc' => '', 'forum_parent_id' => bp_forums_parent_forum_id(), 'forum_order' => false, 'forum_is_category' => 0 ); $r = wp_parse_args( $args, $defaults ); -
); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); } function bp_forums_update_forum( $args = '' ) { do_action( 'bbpress_init' ); $defaults = array( 'forum_id' => '', 'forum_name' => '', 'forum_desc' => '', 'forum_slug' => '', 'forum_parent_id' => bp_forums_parent_forum_id(), 'forum_order' => false, 'forum_is_category' => 0 ); -
return bb_update_forum( array( 'forum_id' => (int)$forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); } /** Topic Functions ***********************************************************/ function bp_forums_get_forum_topics( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'type' => 'newest', 'forum_id' => false, 'user_id' => false, 'page' => 1, 'per_page' => 15, 'offset' => false, 'number' => false, 'exclude' => false, -
} } else { $topics = array(); } return apply_filters_ref_array( 'bp_forums_get_forum_topics', array( &$topics, &$r ) ); } function bp_forums_get_topic_details( $topic_id ) { do_action( 'bbpress_init' ); $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); return $query->results[0]; } function bp_forums_get_topic_id_from_slug( $topic_slug ) { do_action( 'bbpress_init' ); if ( empty( $topic_slug ) ) -
function bp_forums_get_topic_details( $topic_id ) { do_action( 'bbpress_init' ); $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); return $query->results[0]; } function bp_forums_get_topic_id_from_slug( $topic_slug ) { do_action( 'bbpress_init' ); if ( empty( $topic_slug ) ) return false; return bb_get_id_from_slug( 'topic', $topic_slug ); } function bp_forums_new_topic( $args = '' ) { global $bp; -
if ( empty( $topic_slug ) ) return false; return bb_get_id_from_slug( 'topic', $topic_slug ); } function bp_forums_new_topic( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'topic_title' => '', 'topic_slug' => '', 'topic_text' => '', 'topic_poster' => $bp->loggedin_user->id, // accepts ids 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names 'topic_start_time' => bp_core_current_time(), -
do_action( 'bp_forums_new_topic', $topic_id ); return $topic_id; } function bp_forums_update_topic( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'topic_id' => false, 'topic_title' => '', 'topic_text' => '', 'topic_tags' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); -
// Remove all outstanding invites for this group groups_delete_all_group_invites( $group_id ); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->id ); // Remove forum if component is active and current group has one if ( bp_is_active( 'forums' ) && $forum_id = groups_get_groupmeta( $group_id, 'forum_id' ) ) { do_action( 'bbpress_init' ); bb_delete_forum( $forum_id ); } do_action( 'groups_delete_group', $group_id); return true; } function groups_is_valid_status( $status ) { global $bp; -
if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) return false; return bp_forums_get_topic_details( $topic_id ); } function bp_forums_sticky_topic( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'topic_id' => false, 'mode' => 'stick' // stick/unstick ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( 'stick' == $mode ) -
else if ( 'unstick' == $mode ) return bb_unstick_topic( $topic_id ); return false; } function bp_forums_openclose_topic( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'topic_id' => false, 'mode' => 'close' // stick/unstick ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( 'close' == $mode ) -
else if ( 'open' == $mode ) return bb_open_topic( $topic_id ); return false; } function bp_forums_delete_topic( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'topic_id' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); return bb_delete_topic( $topic_id, 1 ); } -
$r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); return bb_delete_topic( $topic_id, 1 ); } function bp_forums_total_topic_count() { global $bbdb; do_action( 'bbpress_init' ); if ( isset( $bbdb ) ) { if ( bp_is_active( 'groups' ) ) { $groups_table_sql = groups_add_forum_tables_sql(); $groups_where_sql = groups_add_forum_where_sql( "t.topic_status = 0" ); } else { $groups_table_sql = ''; $groups_where_sql = "t.topic_status = 0"; } $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$bbdb->topics} AS t {$groups_table_sql} WHERE {$groups_where_sql}" ) ); -
* @package BuddyPress * * @param int $user_id ID of the user being queried. Falls back on displayed user, then loggedin * @param str $type The current filter/sort type. 'active', 'popular', 'unreplied' * @return int $count The topic count */ function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) { global $bp; do_action( 'bbpress_init' ); if ( !$user_id ) $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; if ( class_exists( 'BB_Query' ) ) { $args = array( 'topic_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true -
* @package BuddyPress * @since 1.5 * * @param int $user_id Defaults to displayed user, then to logged-in user * @return int $count */ function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) { global $bp; do_action( 'bbpress_init' ); if ( !$user_id ) $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); if ( !$user_id ) return 0; if ( class_exists( 'BB_Query' ) ) { $query = new BB_Query( 'post', array( 'post_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) ); -
unset( $sql, $total_sql ); return array( 'groups' => $paged_groups, 'total' => $total_groups ); } function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) { global $wpdb, $bp, $bbdb; if ( !$bbdb ) do_action( 'bbpress_init' ); if ( $limit && $page ) { $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); } if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) $hidden_sql = " AND g.status != 'hidden'"; if ( !empty( $search_terms ) ) { $search_terms = like_escape( $wpdb->escape( $search_terms ) ); -
} return array( 'groups' => $paged_groups, 'total' => $total_groups ); } function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) { global $wpdb, $bp, $bbdb; if ( !$bbdb ) do_action( 'bbpress_init' ); if ( $limit && $page ) { $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); } if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) $hidden_sql = " AND g.status != 'hidden'"; if ( $search_terms ) { $search_terms = like_escape( $wpdb->escape( $search_terms ) ); -
$topics[$key]->topic_last_poster_displayname = ''; } return $topics; } /** Post Functions ************************************************************/ function bp_forums_get_topic_posts( $args = '' ) { do_action( 'bbpress_init' ); $defaults = array( 'topic_id' => false, 'page' => 1, 'per_page' => 15, 'order' => 'ASC' ); $args = wp_parse_args( $args, $defaults ); $query = new BB_Query( 'post', $args, 'get_thread' ); -
); $args = wp_parse_args( $args, $defaults ); $query = new BB_Query( 'post', $args, 'get_thread' ); return bp_forums_get_post_extras( $query->results ); } function bp_forums_get_post( $post_id ) { do_action( 'bbpress_init' ); return bb_get_post( $post_id ); } function bp_forums_delete_post( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'post_id' => false -
function bp_forums_get_post( $post_id ) { do_action( 'bbpress_init' ); return bb_get_post( $post_id ); } function bp_forums_delete_post( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'post_id' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); return bb_delete_post( $post_id, 1 ); } -
$r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); return bb_delete_post( $post_id, 1 ); } function bp_forums_insert_post( $args = '' ) { global $bp; do_action( 'bbpress_init' ); $defaults = array( 'post_id' => false, 'topic_id' => false, 'post_text' => '', 'post_time' => bp_core_current_time(), 'poster_id' => $bp->loggedin_user->id, // accepts ids or names 'poster_ip' => $_SERVER['REMOTE_ADDR'], 'post_status' => 0, // use bb_delete_post() instead 'post_position' => false -
} } return apply_filters( 'bp_forums_get_post_extras', $posts ); } function bp_forums_get_forum_topicpost_count( $forum_id ) { global $wpdb, $bbdb; do_action( 'bbpress_init' ); // Need to find a bbPress function that does this return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) ); } function bp_forums_filter_caps( $allcaps ) { global $bp, $wp_roles, $bb_table_prefix; if ( !isset( $bp->loggedin_user->id ) ) return $allcaps;
-
Hook: add_action: bbpress_init instances (1)
-
add_action( 'bbpress_init', 'bp_forums_load_bbpress' )
Source Reference:
-
// Create the first forum. bb_new_forum( array( 'forum_name' => 'Default Forum' ) ); // Set the site URI bb_update_option( 'uri', BB_URL ); } register_shutdown_function( create_function( '', 'do_action("bb_shutdown");' ) ); } add_action( 'bbpress_init', 'bp_forums_load_bbpress' ); /* WP to bbP wrapper functions */ function bb_get_current_user() { global $current_user; return $current_user; } function bb_get_user( $user_id ) { return get_userdata( $user_id ); } function bb_cache_users( $users ) {} /** * bbPress needs this class for its usermeta manipulation. */ class BP_Forums_BB_Auth {
-