Group::create( $args, $assoc_args )
Create a group.
Contents
Description Description
OPTIONS OPTIONS
–name=
[–slug=
[–description=
[–creator-id=] : ID of the group creator. [–creator-id=] : ID of the group creator.
default: 1 default: 1
[–slug=
[–status=] : Group status (public, private, hidden). [–status=] : Group status (public, private, hidden).
default: public options:
[–enable-forum=
[–date-created=
[–silent] : Whether to silent the group creation.
[–porcelain] : Return only the new group id.
EXAMPLES EXAMPLES
$ wp bp group create --name="Totally Cool Group"
Success: Group (ID 5465) created: http://example.com/groups/totally-cool-group/
$ wp bp group create --name="Another Cool Group" --description="Cool Group" --creator-id=54 --status=private
Success: Group (ID 6454)6 created: http://example.com/groups/another-cool-group/
Source Source
File: cli/src/group.php
public function create( $args, $assoc_args ) { $r = wp_parse_args( $assoc_args, array( 'name' => '', 'slug' => '', 'description' => '', 'creator-id' => 1, 'enable-forum' => 0, 'date-created' => bp_core_current_time(), ) ); // Auto-generate some stuff. if ( empty( $r['slug'] ) ) { $r['slug'] = groups_check_slug( sanitize_title( $r['name'] ) ); } if ( empty( $r['description'] ) ) { $r['description'] = sprintf( 'Description for group "%s"', $r['name'] ); } $group_id = groups_create_group( array( 'name' => $r['name'], 'slug' => $r['slug'], 'description' => $r['description'], 'creator_id' => $r['creator-id'], 'status' => $r['status'], 'enable_forum' => $r['enable-forum'], 'date_created' => $r['date-created'], ) ); // Silent it before it errors. if ( WP_CLI\Utils\get_flag_value( $assoc_args, 'silent' ) ) { return; } if ( ! is_numeric( $group_id ) ) { WP_CLI::error( 'Could not create group.' ); } groups_update_groupmeta( $group_id, 'total_member_count', 1 ); if ( WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { WP_CLI::log( $group_id ); } else { $group = groups_get_group( array( 'group_id' => $group_id, ) ); $permalink = bp_get_group_permalink( $group ); WP_CLI::success( sprintf( 'Group (ID %d) created: %s', $group_id, $permalink ) ); } }
Expand full source code Collapse full source code View on Trac