groups_edit_group_settings( int $group_id, bool $enable_forum, string $status, string|bool $invite_status = false, int|bool $parent_id = false )

Edit the base details for a group.


Description Description

These are the settings that appear on the Settings page of the group’s Admin section (privacy settings, "enable forum", invitation status).


Top ↑

Parameters Parameters

$group_id

(int) (Required) ID of the group.

$enable_forum

(bool) (Required) Whether to enable a forum for the group.

$status

(string) (Required) Group status. 'public', 'private', 'hidden'.

$invite_status

(string|bool) (Optional) Who is allowed to send invitations to the group. 'members', 'mods', or 'admins'.

Default value: false

$parent_id

(int|bool) (Optional) Parent group ID.

Default value: false


Top ↑

Return Return

(bool) True on success, false on failure.


Source Source

File: bp-groups/bp-groups-functions.php

function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status = false, $parent_id = false ) {

	$group = groups_get_group( $group_id );
	$group->enable_forum = $enable_forum;

	/**
	 * Before we potentially switch the group status, if it has been changed to public
	 * from private and there are outstanding membership requests, auto-accept those requests.
	 */
	if ( 'private' == $group->status && 'public' == $status )
		groups_accept_all_pending_membership_requests( $group->id );

	// Now update the status.
	$group->status = $status;

	// Update the parent ID if necessary.
	if ( false !== $parent_id ) {
		$group->parent_id = $parent_id;
	}

	if ( !$group->save() )
		return false;

	// Set the invite status.
	if ( $invite_status )
		groups_update_groupmeta( $group->id, 'invite_status', $invite_status );

	groups_update_groupmeta( $group->id, 'last_activity', bp_core_current_time() );

	/**
	 * Fires after the update of a groups settings.
	 *
	 * @since 1.0.0
	 *
	 * @param int $id ID of the group that was updated.
	 */
	do_action( 'groups_settings_updated', $group->id );

	return true;
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.