bbp_save_forum_extras( int $forum_id )
Handle the saving of core forum metadata (Status, Visibility, and Type)
Description
Parameters
- $forum_id
-
(Required)
Return
(If) forum ID is empty
Source
File: bp-forums/forums/functions.php
function bbp_save_forum_extras( $forum_id = 0 ) { // Validate the forum ID $forum_id = bbp_get_forum_id( $forum_id ); // Bail if forum ID is empty if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) return; /** Forum Status ******************************************************/ if ( !empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) { if ( 'closed' === $_POST['bbp_forum_status'] && !bbp_is_forum_closed( $forum_id, false ) ) { bbp_close_forum( $forum_id ); } elseif ( 'open' === $_POST['bbp_forum_status'] && bbp_is_forum_closed( $forum_id, false ) ) { bbp_open_forum( $forum_id ); } } /** Forum Type ********************************************************/ if ( !empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) { if ( 'category' === $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) ) { bbp_categorize_forum( $forum_id ); } elseif ( 'forum' === $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) { bbp_normalize_forum( $forum_id ); } } /** Forum Visibility **************************************************/ if ( !empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ) ) ) { // Get forums current visibility $visibility = bbp_get_forum_visibility( $forum_id ); // What is the new forum visibility setting? switch ( $_POST['bbp_forum_visibility'] ) { // Hidden case bbp_get_hidden_status_id() : bbp_hide_forum( $forum_id, $visibility ); break; // Private case bbp_get_private_status_id() : bbp_privatize_forum( $forum_id, $visibility ); break; // Publish (default) case bbp_get_public_status_id() : default : bbp_publicize_forum( $forum_id, $visibility ); break; } } }
Changelog
Version | Description |
---|---|
bbPress (r3678) | Introduced. |
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.