Group Membership
Topics
Schema
The schema defines all the fields that exist for a group member object.
| idinteger | Unique identifier for the member. Read only Context: embed,view,edit | 
| namestring | Display name for the member. Context: embed,view,edit | 
| mention_namestring | The name used for that user in @-mentions. Context: embed,view,edit | 
| linkstring, uri | Profile URL of the member. Read only Context: embed,view,edit | 
| user_loginstring | A numeric identifier for the member. Required Context: embed,view,edit | 
| member_typesarray | Member types associated with the member. Read only Context: embed,view,edit | 
| registered_datestring or null | Registration date for the member, in the site’s timezone. Read only Context: edit | 
| registered_date_gmtstring or null | Registration date for the member, as GMT. Read only Context: edit | 
| passwordstring | Password for the member (never included). Required Context: none | 
| rolesarray | Roles assigned to the member. Context: edit | 
| capabilitiesobject | All capabilities assigned to the member. Read only Context: edit | 
| extra_capabilitiesobject | All capabilities assigned to the member. Read only Context: edit | 
| xprofile(1)array | Member XProfile groups and its fields. Read only Context: view,edit | 
| friendship_status(2)boolean | Whether the logged in user has a friendship relationship with the fetched user. Read only Context: view,edit | 
| friendship_status_slug(2)string | lug of the friendship relationship status the logged in user has with the fetched user. Read only One of: is_friend,not_friends,pending,awaiting_responseContext: view,edit | 
| avatar_urls(3)object | Avatar URLs for the member (Full & Thumb sizes). Read only Context: embed,view,edit | 
| is_confirmedinteger | 1if the membership of this user has been confirmed,0otherwise.Context: view,editOne of: 0,1 | 
| is_modinteger | 1if this member is a Group moderator,0otherwise.Context: view,editOne of: 0,1 | 
| is_admininteger | 1if this member is a Group administrator,0otherwise.Context: view,editOne of: 0,1 | 
| is_bannedinteger | 1if this member has been banned from the Group,0otherwise.Context: view,editOne of: 0,1 | 
| date_modifiedstring or null | The date of the last time the membership of this user was modified, in the site’s timezone. Read only Context: view,edit | 
| date_modified_gmtstring or null | The date of the last time the membership of this user was modified, as GMT. Read only Context: view,edit | 
(1) Datas is only fetched if the xProfile component is active
(2) Data is only fetched if the Friends component is active
(3) Only if the WordPress discussion settings allow avatars.
List the Group Members
Arguments
| Name | Type | Description | 
|---|---|---|
| group_id | integer | A unique numeric ID for the Group. Required | 
| context | string | Scope under which the request is made; determines fields present in response. Default: viewOne of: view, embed, edit | 
| page | integer | Current page of the collection. Default: 1 | 
| per_page | integer | Maximum number of Group members to be returned in result set. Default: 10 | 
| search | string | Limit results to members name matching a string. | 
| status | string | Sort the order of results by the status of the group members. Default: last_joinedOne of: last_joined,first_joined,alphabetical,group_activity(1) | 
| roles | array | Ensure result set includes specific Group roles. Default: []One or more of: admin,mod,member,banned | 
| exclude | array | Ensure result set excludes specific member IDs. Default: [] | 
| exclude_admins | boolean | Whether results should exclude group admins and mods. Default: true | 
| exclude_banned | boolean | Whether results should exclude banned group members. Default: true | 
(1) The group_activity status is only available if the Activity BuddyPress component is active.
Definition
GET /buddypress/v1/groups/<group_id>/members
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/4/members',
  type: 'GET',
  data: {
    context: 'view',
    exclude_admins: false
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );
Add a specific Member into a Group
Note: To make a logged in user join a public Group, you need to use the view context. In this case the role argument is not available and the user is added to the Group as a member.
Arguments
| Name | Type | Description | 
|---|---|---|
| group_id | integer | A unique numeric ID for the Group. Required | 
| user_id | integer | A unique numeric ID for the Member to add to the Group. Required Default: the logged in user ID | 
| context | string | Scope under which the request is made; determines fields present in response. Default: editOne of: view, embed, edit | 
| role | string | Group role to assign the user to. Default: memberOne of: admin, mod, member | 
Definition
POST /buddypress/v1/groups/<group_id>/members
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/5/members',
  type: 'POST',
  data: {
    context: 'edit',
    user_id: 3
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );
Promote or demote a specific Group Member
Arguments
| Name | Type | Description | 
|---|---|---|
| group_id | integer | A unique numeric ID for the Group. Required | 
| user_id | integer | A unique numeric ID for the Group Member. Required | 
| context | string | Scope under which the request is made; determines fields present in response. Default: editOne of: view, embed, edit | 
| role | string | Group role to assign the user to. Default: memberOne of: admin, mod, member | 
| action | string | Action used to update a group member. Default: promoteOne of: promote, demote, ban, unban | 
Definition
PUT /buddypress/v1/groups/<group_id>/members/<user_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/5/members/3',
  type: 'PUT',
  data: {
    context: 'edit',
    role: 'mod',
    action: 'promote'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );
Remove a specific Group Member
Arguments
| Name | Type | Description | 
|---|---|---|
| group_id | integer | A unique numeric ID for the Group. Required | 
| user_id | integer | A unique numeric ID for the Group Member. Required | 
| context | string | Scope under which the request is made; determines fields present in response. Default: editOne of: view, embed, edit | 
Definition
DELETE /buddypress/v1/groups/<group_id>/members/<user_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/5/members/3',
  type: 'DELETE',
  data: {
    context: 'edit'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );