bbp_forum_update_forum_status_when_group_updates( $group_id )

Update Forum status depending on the group status

Description

Source

File: bp-forums/functions.php

763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
function bbp_forum_update_forum_status_when_group_updates( $group_id ) {
 
    if ( $group_id ) {
        $forum_ids = array_values( bbp_get_group_forum_ids( $group_id ) );
        if ( ! empty( $forum_ids ) ) {
            // Get the group
            $group = groups_get_group( absint( $group_id ) );
 
            foreach ( $forum_ids as $forum_id ) {
                if ( ! empty( $forum_id ) ) {
 
                    // Set the default forum status
                    switch ( $group->status ) {
                        case 'hidden'  :
                            $status = bbp_get_hidden_status_id();
                            break;
                        case 'private' :
                            $status = bbp_get_private_status_id();
                            break;
                        case 'public'  :
                        default        :
                            $status = bbp_get_public_status_id();
                            break;
                    }
 
                    wp_update_post( array(
                        'ID'          => $forum_id,
                        'post_status' => $status
                    ) );
                }
            }
        }
 
        // Update Forums' internal private and forum ID variables
        bbp_repair_forum_visibility();
    }
}

Changelog

Changelog
Version Description
BuddyBoss 1.1.5 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.