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()

Return

(bool) True on success, false on failure.

Source

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

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
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

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.