bbp_publicize_forum( int $forum_id,  $current_visibility = '' )

Mark the forum as public

Description

Parameters

$forum_id

(Optional) Forum id

Return

(bool) False on failure, true on success

Source

File: bp-forums/forums/functions.php

796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) {
 
    $forum_id = bbp_get_forum_id( $forum_id );
 
    do_action( 'bbp_publicize_forum'$forum_id );
 
    // Get private forums
    $private = bbp_get_private_forum_ids();
 
    // Find this forum in the array
    if ( in_array( $forum_id, $private ) ) {
 
        $offset = array_search( $forum_id, $private );
 
        // Splice around it
        array_splice( $private, $offset, 1 );
 
        // Update private forums minus this one
        update_option( '_bbp_private_forums', array_unique( array_filter( array_values( $private ) ) ) );
    }
 
    // Get hidden forums
    $hidden = bbp_get_hidden_forum_ids();
 
    // Find this forum in the array
    if ( in_array( $forum_id, $hidden ) ) {
 
        $offset = array_search( $forum_id, $hidden );
 
        // Splice around it
        array_splice( $hidden, $offset, 1 );
 
        // Update hidden forums minus this one
        update_option( '_bbp_hidden_forums', array_unique( array_filter( array_values( $hidden ) ) ) );
    }
 
    // Only run queries if visibility is changing
    if ( bbp_get_public_status_id() !== $current_visibility ) {
 
        // Update forums visibility setting
        global $wpdb;
        $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) );
        wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) );
        bbp_clean_post_cache( $forum_id );
    }
 
    do_action( 'bbp_publicized_forum', $forum_id );
 
    return $forum_id;
}

Changelog

Changelog
Version Description
bbPress (r2746) 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.