groups_edit_base_group_details( array $args = array() )
Edit the base details for a group.
Description
These are the settings that appear on the first page of the group’s Admin section (Name, Description, and "Notify members…").
Parameters
- $args
-
(Optional) An array of optional arguments.
- 'group_id'
(int) ID of the group. - 'name'
(string) Name of the group. - 'slug'
(string) Slug of the group. - 'description'
(string) Description of the group. - 'parent_id'
(int) Parent id of the group. - 'notify_members'
(bool) Whether to send an email notification to group members about changes in these details.
Default value: array()
- 'group_id'
Return
(bool) True on success, false on failure.
Source
File: bp-groups/bp-groups-functions.php
function groups_edit_base_group_details( $args = array() ) {
// Backward compatibility with old method of passing arguments.
if ( ! is_array( $args ) || func_num_args() > 1 ) {
_deprecated_argument( __METHOD__, '2.9.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddyboss' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
0 => 'group_id',
1 => 'name',
2 => 'description',
3 => 'notify_members',
);
$args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
}
$r = bp_parse_args( $args, array(
'group_id' => bp_get_current_group_id(),
'name' => null,
'slug' => null,
'description' => null,
'notify_members' => false,
'parent_id' => 0,
), 'groups_edit_base_group_details' );
if ( ! $r['group_id'] ) {
return false;
}
$group = groups_get_group( $r['group_id'] );
$old_group = clone $group;
// Group name, slug can never be empty. Update only if provided.
if ( $r['name'] ) {
$group->name = $r['name'];
}
if ( $r['slug'] && $r['slug'] != $group->slug ) {
$group->slug = groups_check_slug( $r['slug'] );
}
$group->description = $r['description'];
$group->parent_id = $r['parent_id'];
if ( ! $group->save() ) {
return false;
}
// Maybe update the "previous_slug" groupmeta.
if ( $group->slug != $old_group->slug ) {
/*
* If the old slug exists in this group's past, delete that entry.
* Recent previous_slugs are preferred when selecting the current group
* from an old group slug, so we want the previous slug to be
* saved "now" in the groupmeta table and don't need the old record.
*/
groups_delete_groupmeta( $group->id, 'previous_slug', $old_group->slug );
groups_add_groupmeta( $group->id, 'previous_slug', $old_group->slug );
}
if ( $r['notify_members'] ) {
groups_notification_group_updated( $group->id, $old_group );
}
/**
* Fired after a group's details are updated.
*
* @since BuddyPress 2.2.0
*
* @param int $value ID of the group.
* @param BP_Groups_Group $old_group Group object, before being modified.
* @param bool $notify_members Whether to send an email notification to members about the change.
*/
do_action( 'groups_details_updated', $group->id, $old_group, $r['notify_members'] );
return true;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.0.0 | 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.