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

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.