Groups

Schema

The schema defines all the fields that exist for a group object.

id

integer
A unique numeric ID for the Group.
Read only
Context: viewedit
creator_id

integer
The ID of the user who created the Group.
Context: viewedit
name

string
The name of the group.
Context: viewedit
slug

string
The URL-friendly slug for the group.
Context: viewedit
link

string,
uri
The permalink to the Group on the site.
Read only
Context: viewedit
description

object
The raw and rendered descriptions of the Group.
Context: viewedit
status

string
The visibility status of the Group.
Context: viewedit
One of: public, private, hidden
enable_forum

boolean
Whether the group has a forum or not.
Context: viewedit
parent_id

integer
ID of the parent Group.
Context: viewedit
date_created

string or null
The date the Group was created, in the site’s timezone.
Read only
Context: viewedit
date_created_gmt

string or null
The date the Group was created, as GMT.
Read only
Context: viewedit
types

array
The Group Types. See this documentation page for more information about Groupe Types.
Read only
Context: viewedit
admins

array
List of WP_User objects for Group administrators.
Read only
Context: edit
mods

array
List of WP_User objects for moderators.
Read only
Context: edit
total_member_count
integer
Count of all Group members.
Read only
Context: viewedit
last_activity

string or null
The date the Group was last active, in the site’s timezone.
Read only
Context: viewedit
last_activity_gmt

string or null
The date the Group was last active, as GMT.
Read only
Context: viewedit
last_activity_diff

string
The human diff time the Group was last active, in the site’s timezone.
Read only
Context: viewedit
avatar_urls (1)

object
Avatar URLs for the group (Full & Thumb sizes).
Read only
Context: viewedit

(1) Only if Group Avatar uploads are enabled on the community site.

Top ↑

List User Groups

Top ↑

Arguments

NameTypeDescription
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of : view, edit
pageintegerCurrent page of the collection.
Default: 1
per_pageintegerMaximum number of Groups to be returned in result set.
Default: 10
searchstringLimit results to Group names or descriptions matching a string.
typestringShorthand for certain orderby/order combinations.
Default: active
One of: active, newest, alphabetical, random, popular, most-forum-topics, most-forum-posts
orderstringOrder sort attribute ascending or descending.
Default: desc
One of : asc, desc
orderbystringOrder Groups by which attribute.
Default: date_created
One of : date_created, last_activity, total_member_count, name, random
statusarrayGroup statuses to limit results to.
Default: []
One or more of : public, private, hidden
user_idintegerPass a user_id to limit to only Groups that this user is a member of.
Default: 0
parent_idarrayGet Groups that are children of the specified Group(s) IDs.
Default: []
metaarrayGet Groups based on their meta data information.
Default: []
includearrayEnsure result set includes Groups with specific IDs.
Default: []
excludearrayEnsure result set excludes Groups with specific IDs.
Default: []
group_typestringLimit 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_forumbooleanWhether the group has a forum enabled.
Default: false
show_hiddenbooleanWhether results should include hidden groups.
Default: false
populate_extrasbooleanWhether to fetch extra BP data about the returned groups.
Default: false

Top ↑

Definition

GET /buddypress/v1/groups

Top ↑

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: 'GET',
  data: {
    context: 'view'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Create a User Group

Top ↑

Arguments

NameTypeDescription
creator_idintegerThe ID of the user who created the Group.
Default: the logged in user ID
namestringThe name of the Group.
Required
slugstringThe URL-friendly slug for the Group.
descriptionstringThe description of the Group.
Required
statusstringThe status of the Group.
Default: public
One of : public, private, hidden
enable_forumbooleanWhether the Group has a forum or not.
parent_idintegerID of the parent Group.
typesarrayThe Group Types. See this documentation page for more information about Group Types.

Top ↑

Definition

POST /buddypress/v1/groups

Top ↑

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;
} );

Top ↑

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.

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the Group.
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of : view, edit
populate_extrasbooleanWhether to fetch extra BP data about the returned group.
Default: false

Top ↑

Definition

GET /buddypress/v1/groups/<group_id>

Top ↑

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;
} );

Top ↑

Update a User Group

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the Group.
creator_idintegerThe ID of the user who created the Group.
namestringThe name of the Group.
descriptionstringThe description of the Group.
statusstringThe status of the Group.
Default: public
One of : public, private, hidden
enable_forumbooleanWhether the Group has a forum or not.
parent_idintegerID of the parent Group.
typesstringAssign 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_typesstringAppend 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_typesstringRemove 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.

Top ↑

Definition

PUT /buddypress/v1/groups/<group_id>

Top ↑

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;
} );

Top ↑

Delete a User Group

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the Group.

Top ↑

Definition

DELETE /buddypress/v1/groups/<group_id>

Top ↑

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;
} );

Top ↑

List the User Groups of the logged in member

Top ↑

Arguments

NameTypeDescription
maxintegerThe maximum amount of groups the user is member of to return. Defaults to all groups.
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of : view, edit

Top ↑

Definition

GET /buddypress/v1/groups/me

Top ↑

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;
} );