BBP_Forums_Group_Extension::toggle_group_forum( int $group_id, bool $enabled = false,  $forum_id = false )

Toggle the enable_forum group setting on or off

Description

Parameters

$group_id

(Required) The group to toggle

$enabled

(Optional) True for on, false for off

Default value: false

Return

(False) if group is not found, otherwise return the group

Source

File: bp-forums/groups.php

	public function toggle_group_forum( $group_id = 0, $enabled = false ) {

		// Get the group
		$group = groups_get_group( array( 'group_id' => $group_id ) );

		// Bail if group cannot be found
		if ( empty( $group ) )
			return false;

		// Set forum enabled status
		$group->enable_forum = (int) $enabled;

		// Save the group
		$group->save();

		// Maybe disconnect forum from group
		if ( empty( $enabled ) ) {
			$this->disconnect_forum_from_group( $group_id );
		}

		// Update Forums' internal private and forum ID variables
		bbp_repair_forum_visibility();

		// Return the group
		return $group;
	}

Changelog

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