Contents
bbp_get_forum_id( $forum_id )
Return the forum id
Description
Parameters
- $forum_id
-
(Optional) Used to check emptiness
Return
(int) The forum id
Source
File: bp-forums/forums/template.php
function bbp_get_forum_id( $forum_id = 0 ) { global $wp_query; $bbp = bbpress(); // Easy empty checking if ( !empty( $forum_id ) && is_numeric( $forum_id ) ) { $bbp_forum_id = $forum_id; // Currently inside a forum loop } elseif ( !empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) { $bbp_forum_id = $bbp->forum_query->post->ID; // Currently inside a search loop } elseif ( !empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) { $bbp_forum_id = $bbp->search_query->post->ID; // Currently viewing a forum } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && !empty( $bbp->current_forum_id ) ) { $bbp_forum_id = $bbp->current_forum_id; // Currently viewing a forum } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) { $bbp_forum_id = $wp_query->post->ID; // Currently viewing a topic } elseif ( bbp_is_single_topic() ) { $bbp_forum_id = bbp_get_topic_forum_id(); // Fallback } else { $bbp_forum_id = 0; } return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id ); }
Changelog
Version | Description |
---|---|
bbPress (r2464) | Introduced. |
Related
Uses
Uses | Description |
---|---|
bp-forums/topics/template.php: bbp_get_topic_forum_id() |
Return the forum id a topic belongs to |
bp-forums/classes/class-bbpress.php: bbpress() |
The main function responsible for returning the one true bbPress Instance to functions everywhere. |
bp-forums/common/template.php: bbp_is_forum_edit() |
Check if current page is a forum edit page |
bp-forums/common/template.php: bbp_is_single_topic() |
Viewing a single topic |
bp-forums/common/template.php: bbp_is_forum() |
Check if current page is a Forums forum |
bp-forums/common/template.php: bbp_is_single_forum() |
Viewing a single forum |
Used By | Description |
---|---|
bp-forums/classes/class-bp-rest-forums-endpoint.php: BP_REST_Forums_Endpoint::get_forum_current_user_permissions() |
Forum permissions for the current user. |
bp-forums/templates/default/bbpress-functions.php: BBP_Default::media_localize_script() |
Localize scripts for Media component for forums |
bp-forums/core/theme-compat.php: bbp_template_include_theme_compat() |
Reset main query vars and filter ‘the_content’ to output a Forums template part as needed. |
bp-forums/topics/template.php: bbp_has_topics() |
The main topic loop. WordPress makes this easy for us |
bp-forums/topics/functions.php: bbp_display_topics_feed_rss2() |
Output an RSS2 feed of topics, based on the query passed. |
bp-forums/topics/functions.php: bbp_update_topic() |
Handle all the extra meta stuff from posting a new topic |
bp-forums/topics/functions.php: bbp_move_topic_handler() |
Handle the moving of a topic from one forum to another. This includes walking up the old and new branches and updating the counts. |
bp-forums/users/template.php: bbp_current_user_can_access_create_forum_form() |
Performs a series of checks to ensure the current user can create forums. |
bp-forums/users/template.php: bbp_user_can_view_forum() |
Check if the user can access a specific forum |
bp-forums/users/template.php: bbp_get_user_subscribe_link() |
Return the link to subscribe/unsubscribe from a forum or topic |
bp-forums/users/functions.php: bbp_is_user_subscribed_to_forum() |
Check if a forum is in user’s subscription list or not |
bp-forums/users/functions.php: bbp_get_forum_subscribers() |
Get the users who have subscribed to the forum |
bp-forums/groups.php: BBP_Forums_Group_Extension::topic_pagination() |
Fix pagination of topics on forum view |
bp-forums/groups.php: BBP_Forums_Group_Extension::new_forum() |
Creating a group forum or category (including root for group) |
bp-forums/groups.php: BBP_Forums_Group_Extension::remove_forum() |
Removing a group forum or category (including root for group) |
bp-forums/forums/template.php: bbp_get_forum_replies_feed_link() |
Retrieve the link for the forum replies feed |
bp-forums/forums/template.php: bbp_get_form_forum_type_dropdown() |
Return the forum type dropdown |
bp-forums/forums/template.php: bbp_get_form_forum_status_dropdown() |
Return the forum status dropdown |
bp-forums/forums/template.php: bbp_get_form_forum_visibility_dropdown() |
Return the forum visibility dropdown |
bp-forums/forums/template.php: bbp_get_forum_topics_feed_link() |
Retrieve the link for the forum feed |
bp-forums/forums/template.php: bbp_get_forum_class() |
Return the row class of a forum |
bp-forums/forums/template.php: bbp_is_forum_private() |
Is the forum private? |
bp-forums/forums/template.php: bbp_is_forum_hidden() |
Is the forum hidden? |
bp-forums/forums/template.php: bbp_get_forum_author_display_name() |
Return the author of the forum |
bp-forums/forums/template.php: bbp_get_forum_author_id() |
Return the author ID of the forum |
bp-forums/forums/template.php: bbp_get_forum_visibility() |
Return the visibility of the forum |
bp-forums/forums/template.php: bbp_get_forum_type() |
Return the type of forum (category/forum/etc. |
bp-forums/forums/template.php: bbp_is_forum_category() |
Is the forum a category? |
bp-forums/forums/template.php: bbp_is_forum_closed() |
Is the forum closed? |
bp-forums/forums/template.php: bbp_is_forum_public() |
Is the forum public? |
bp-forums/forums/template.php: bbp_get_forum_status() |
Return the status of the forum |
bp-forums/forums/template.php: bbp_get_forum_subforum_count() |
Return total subforum count of a forum |
bp-forums/forums/template.php: bbp_get_forum_topic_count() |
Return total topic count of a forum |
bp-forums/forums/template.php: bbp_get_forum_reply_count() |
Return total post count of a forum |
bp-forums/forums/template.php: bbp_get_forum_post_count() |
Return total post count of a forum |
bp-forums/forums/template.php: bbp_get_forum_topic_count_hidden() |
Return total hidden topic count of a forum (hidden includes trashed and spammed topics) |
bp-forums/forums/template.php: bbp_get_forum_last_reply_author_link() |
Return link to author of last reply of forum |
bp-forums/forums/template.php: bbp_get_forum_last_reply_permalink() |
Return the link to the last reply in a forum |
bp-forums/forums/template.php: bbp_get_forum_last_reply_url() |
Return the url to the last reply in a forum |
bp-forums/forums/template.php: bbp_get_forum_last_reply_author_id() |
Return author ID of last reply of forum |
bp-forums/forums/template.php: bbp_get_forum_last_topic_title() |
Return the title of the last topic inside a forum |
bp-forums/forums/template.php: bbp_get_forum_last_topic_permalink() |
Return the link to the last topic in a forum |
bp-forums/forums/template.php: bbp_get_forum_last_topic_author_id() |
Return the author ID of the last topic of a forum |
bp-forums/forums/template.php: bbp_get_forum_last_topic_author_link() |
Return link to author of last topic of forum |
bp-forums/forums/template.php: bbp_get_forum_last_reply_id() |
Return the forums last reply id |
bp-forums/forums/template.php: bbp_get_forum_last_reply_title() |
Return the title of the last reply inside a forum |
bp-forums/forums/template.php: bbp_get_forum_last_topic_id() |
Return the forum’s last topic id |
bp-forums/forums/template.php: bbp_get_forum_freshness_link() |
Returns link to the most recent activity inside a forum. |
bp-forums/forums/template.php: bbp_get_forum_parent_id() |
Return ID of forum parent, if exists |
bp-forums/forums/template.php: bbp_get_forum_ancestors() |
Return array of parent forums |
bp-forums/forums/template.php: bbp_forum_get_subforums() |
Return subforums of given forum |
bp-forums/forums/template.php: bbp_get_forum_last_active_id() |
Return the forums last active ID |
bp-forums/forums/template.php: bbp_get_forum_last_active_time() |
Return the forums last update date/time (aka freshness) |
bp-forums/forums/template.php: bbp_get_forum() |
Gets a forum |
bp-forums/forums/template.php: bbp_get_forum_permalink() |
Return the link to the forum |
bp-forums/forums/template.php: bbp_get_forum_title() |
Return the title of the forum |
bp-forums/forums/template.php: bbp_get_forum_content() |
Return the content of the forum |
bp-forums/forums/template.php: bbp_forum_id() |
Output forum id |
bp-forums/forums/functions.php: bbp_untrashed_forum() |
Called after untrashing a forum |
bp-forums/forums/template.php: bbp_has_forums() |
The main forum loop. |
bp-forums/forums/functions.php: bbp_untrash_forum_topics() |
Trash all topics inside a forum |
bp-forums/forums/functions.php: bbp_delete_forum() |
Called before deleting a forum. |
bp-forums/forums/functions.php: bbp_trash_forum() |
Called before trashing a forum |
bp-forums/forums/functions.php: bbp_untrash_forum() |
Called before untrashing a forum |
bp-forums/forums/functions.php: bbp_deleted_forum() |
Called after deleting a forum |
bp-forums/forums/functions.php: bbp_trashed_forum() |
Called after trashing a forum |
bp-forums/forums/functions.php: bbp_forum_enforce_private() |
Check if it’s a private forum or a topic or reply of a private forum and if the user can’t view it, then sets a 404 |
bp-forums/forums/functions.php: bbp_check_forum_edit() |
Redirect if unathorized user is attempting to edit a forum |
bp-forums/forums/functions.php: bbp_delete_forum_topics() |
Delete all topics (and their replies) for a specific forum ID |
bp-forums/forums/functions.php: bbp_trash_forum_topics() |
Trash all topics inside a forum |
bp-forums/forums/functions.php: bbp_forum_enforce_hidden() |
Check if it’s a hidden forum or a topic or reply of a hidden forum and if the user can’t view it, then sets a 404 |
bp-forums/forums/functions.php: bbp_update_forum_subforum_count() |
Update the forum sub-forum count |
bp-forums/forums/functions.php: bbp_update_forum_topic_count() |
Adjust the total topic count of a forum |
bp-forums/forums/functions.php: bbp_update_forum_topic_count_hidden() |
Adjust the total hidden topic count of a forum (hidden includes trashed and spammed topics) |
bp-forums/forums/functions.php: bbp_update_forum_reply_count() |
Adjust the total reply count of a forum |
bp-forums/forums/functions.php: bbp_hide_forum() |
Mark the forum as hidden |
bp-forums/forums/functions.php: bbp_remove_forum_from_all_subscriptions() |
Remove a deleted forum from all users’ subscriptions |
bp-forums/forums/functions.php: bbp_bump_forum_topic_count() |
Bump the total topic count of a forum |
bp-forums/forums/functions.php: bbp_bump_forum_topic_count_hidden() |
Bump the total hidden topic count of a forum |
bp-forums/forums/functions.php: bbp_bump_forum_reply_count() |
Bump the total topic count of a forum |
bp-forums/forums/functions.php: bbp_update_forum_last_topic_id() |
Update the forum last topic id |
bp-forums/forums/functions.php: bbp_update_forum_last_reply_id() |
Update the forum last reply id |
bp-forums/forums/functions.php: bbp_update_forum_last_active_id() |
Update the forum last active post id |
bp-forums/forums/functions.php: bbp_update_forum_last_active_time() |
Update the forums last active date/time (aka freshness) |
bp-forums/forums/functions.php: bbp_privatize_forum() |
Mark the forum as private |
bp-forums/forums/functions.php: bbp_new_forum_handler() |
Handles the front end forum submission |
bp-forums/forums/functions.php: bbp_edit_forum_handler() |
Handles the front end edit forum submission |
bp-forums/forums/functions.php: bbp_save_forum_extras() |
Handle the saving of core forum metadata (Status, Visibility, and Type) |
bp-forums/forums/functions.php: bbp_close_forum() |
Closes a forum |
bp-forums/forums/functions.php: bbp_open_forum() |
Opens a forum |
bp-forums/forums/functions.php: bbp_categorize_forum() |
Make the forum a category |
bp-forums/forums/functions.php: bbp_normalize_forum() |
Remove the category status from a forum |
bp-forums/forums/functions.php: bbp_publicize_forum() |
Mark the forum as public |
bp-forums/common/shortcodes.php: BBP_Shortcodes::display_topic_form() |
Display the topic form in an output buffer and return to ensure post/page contents are displayed first. |
bp-forums/common/template.php: bbp_forum_form_fields() |
Output the required hidden fields when creating/editing a forum |
bp-forums/common/functions.php: bbp_request_feed_trap() |
This function is hooked into the WordPress ‘request’ action and is responsible for sniffing out the query vars and serving up RSS2 feeds if the stars align and the user has requested a feed of any Forums type. |
bp-forums/common/functions.php: bbp_notify_topic_subscribers() |
Sends notification emails for new replies to subscribed topics |
bp-forums/common/functions.php: bbp_notify_forum_subscribers() |
Sends notification emails for new topics to subscribed forums |
bp-forums/activity.php: BBP_BuddyPress_Activity::reply_create() |
Record an activity stream entry when a reply is created |
bp-forums/activity.php: BBP_BuddyPress_Activity::topic_create() |
Record an activity stream entry when a topic is created or updated |
bp-forums/functions.php: bbp_remove_forum_id_from_all_groups() |
Remove a forum from all groups |
bp-forums/functions.php: bbp_is_forum_group_forum() |
Return true if a forum is a group forum |
bp-forums/functions.php: bbp_remove_forum_id_from_group() |
Remove a forum from a group |
bp-forums/functions.php: bbp_get_forum_group_ids() |
Get group ID’s for a forum |
bp-forums/functions.php: bbp_update_forum_group_ids() |
Update group ID’s for a forum |
bp-forums/functions.php: bbp_add_group_id_to_forum() |
Add a group to a forum |
bp-forums/functions.php: bbp_add_forum_id_to_group() |
Remove a forum from a group |
bp-forums/functions.php: bbp_remove_group_id_from_forum() |
Remove a group from a forum |
bp-forums/replies/template.php: bbp_get_reply_forum_id() |
Return the forum id a reply belongs to |
bp-forums/replies/functions.php: bbp_update_reply() |
Handle all the extra meta stuff from posting a new reply or editing a reply |
bp-forums/replies/functions.php: bbp_update_reply_forum_id() |
Update the reply with its forum id it is in |
bp-forums/search/template.php: bbp_the_search_result() |
Loads up the current search result in the loop |
bp-core/deprecated/buddyboss/1.0.php: bbp_get_single_forum_description() |
Return a fancy description of the current forum, including total topics, total replies, and last activity. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.