Groups
Topics
Schema
The schema defines all the fields that exist for a group object.
idinteger | A unique numeric ID for the Group. Read only Context: view, edit |
creator_idinteger | The ID of the user who created the Group. Context: view, edit |
namestring | The name of the group. Context: view, edit |
slugstring | The URL-friendly slug for the group. Context: view, edit |
linkstring, uri | The permalink to the Group on the site. Read only Context: view, edit |
descriptionobject | The raw and rendered descriptions of the Group. Context: view, edit |
statusstring | The visibility status of the Group. Context: view, editOne of: public, private, hidden |
enable_forumboolean | Whether the group has a forum or not. Context: view, edit |
parent_idinteger | ID of the parent Group. Context: view, edit |
date_createdstring or null | The date the Group was created, in the site’s timezone. Read only Context: view, edit |
date_created_gmtstring or null | The date the Group was created, as GMT. Read only Context: view, edit |
typesarray | The Group Types. See this documentation page for more information about Groupe Types. Read only Context: view, edit |
adminsarray | List of WP_User objects for Group administrators. Read only Context: edit |
modsarray | List of WP_User objects for moderators.Read only Context: edit |
total_member_countinteger | Count of all Group members. Read only Context: |
last_activitystring or null | The date the Group was last active, in the site’s timezone. Read only Context: |
last_activity_gmtstring or null | The date the Group was last active, as GMT. Read only Context: |
last_activity_diffstring | The human diff time the Group was last active, in the site’s timezone. Read only Context: |
avatar_urls (1)object | Avatar URLs for the group (Full & Thumb sizes). Read only Context: view, edit |
(1) Only if Group Avatar uploads are enabled on the community site.
List User Groups
Arguments
| Name | Type | Description |
|---|---|---|
| context | string | Scope under which the request is made; determines fields present in response. Default: viewOne of : view, edit |
| page | integer | Current page of the collection. Default: 1 |
| per_page | integer | Maximum number of Groups to be returned in result set. Default: 10 |
| search | string | Limit results to Group names or descriptions matching a string. |
| type | string | Shorthand for certain orderby/order combinations. Default: active One of: active, newest, alphabetical, random, popular, most-forum-topics, most-forum-posts |
| order | string | Order sort attribute ascending or descending. Default: desc One of : asc, desc |
| orderby | string | Order Groups by which attribute. Default: date_createdOne of : date_created, last_activity, total_member_count, name, random |
| status | array | Group statuses to limit results to. Default: [] One or more of : public, private, hidden |
| user_id | integer | Pass a user_id to limit to only Groups that this user is a member of. Default: 0 |
| parent_id | array | Get Groups that are children of the specified Group(s) IDs. Default: [] |
| meta | array | Get Groups based on their meta data information. Default: [] |
| include | array | Ensure result set includes Groups with specific IDs. Default: [] |
| exclude | array | Ensure result set excludes Groups with specific IDs. Default: [] |
| group_type | string | Limit results set a to certain Group type. See this documentation page for more information about Group Types. One of: The active Group types on the site. |
| enable_forum | boolean | Whether the group has a forum enabled. Default: false |
| show_hidden | boolean | Whether results should include hidden groups. Default: false |
| populate_extras | boolean | Whether to fetch extra BP data about the returned groups. Default: false |
Definition
GET /buddypress/v1/groups
Example of use
bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups',
type: 'GET',
data: {
context: 'view'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
Create a User Group
Arguments
| Name | Type | Description |
|---|---|---|
| creator_id | integer | The ID of the user who created the Group. Default: the logged in user ID |
| name | string | The name of the Group. Required |
| slug | string | The URL-friendly slug for the Group. |
| description | string | The description of the Group. Required |
| status | string | The status of the Group. Default: publicOne of : public, private, hidden |
| enable_forum | boolean | Whether the Group has a forum or not. |
| parent_id | integer | ID of the parent Group. |
| types | array | The Group Types. See this documentation page for more information about Group Types. |
Definition
POST /buddypress/v1/groups
Example of use
Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups',
type: 'POST',
data: {
context: 'edit',
creator_id: 4,
name: 'BuddyPress Group', // Required.
description: 'My beautiful group', // Required.
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
Retrieve a specific User Group
Note: If you want to fetch activities posted in a specific User Group, please use the Activity Endpoint to fetch these using the group_id argument set to the ID of the User Group.
Arguments
| Name | Type | Description |
|---|---|---|
| id | integer | A unique numeric ID for the Group. |
| context | string | Scope under which the request is made; determines fields present in response. Default: view One of : view, edit |
| populate_extras | boolean | Whether to fetch extra BP data about the returned group. Default: false |
Definition
GET /buddypress/v1/groups/<group_id>
Example of use
Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups/51',
type: 'GET',
data: {
context: 'view'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
Update a User Group
Arguments
| Name | Type | Description |
|---|---|---|
| id | integer | A unique numeric ID for the Group. |
| creator_id | integer | The ID of the user who created the Group. |
| name | string | The name of the Group. |
| description | string | The description of the Group. |
| status | string | The status of the Group. Default: publicOne of : public, private, hidden |
| enable_forum | boolean | Whether the Group has a forum or not. |
| parent_id | integer | ID of the parent Group. |
| types | string | Assign one or more type to a group. To assign more than one type, use a comma separated list of types. See this documentation page for more information about Group Types. |
| append_types | string | Append one or more type to a group. To append more than one type, use a comma separated list of types. See this documentation page for more information about Group Types. |
| remove_types | string | Remove one or more type of a group. To remove more than one type, use a comma separated list of types. See this documentation page for more information about Group Types. |
Definition
PUT /buddypress/v1/groups/<group_id>
Example of use
Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups/51',
type: 'PUT',
data: {
context: 'edit',
name: 'My awesome Group'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
Delete a User Group
Arguments
| Name | Type | Description |
|---|---|---|
| id | integer | A unique numeric ID for the Group. |
Definition
DELETE /buddypress/v1/groups/<group_id>
Example of use
Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups/51',
type: 'DELETE',
data: {
context: 'edit'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
List the User Groups of the logged in member
Arguments
| Name | Type | Description |
|---|---|---|
| max | integer | The maximum amount of groups the user is member of to return. Defaults to all groups. |
| context | string | Scope under which the request is made; determines fields present in response. Default: viewOne of : view, edit |
Definition
GET /buddypress/v1/groups/me
Example of use
Alert: To use the bp.apiRequest function, you need to enqueue the bp-api-request JavaScript or use it as a dependency of your script. Refer to this page to know more about loading JavaScript files in WordPress.
bp.apiRequest( {
path: 'buddypress/v1/groups/me',
type: 'GET',
data: {
context: 'view'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );