Group Membership

Schema Schema

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

id

integer
Unique identifier for the member.
Read only
Context: embedviewedit
name

string
Display name for the member.
Context: embed, view, edit
mention_name

string
The name used for that user in @-mentions.
Context: embedviewedit
link

string,
uri
Profile URL of the member.
Read only
Context: embedviewedit
user_login

string
A numeric identifier for the member.
Required
Context: embedviewedit
member_types

object
Member types associated with the member.
Read only
Context: embedviewedit
registered_date

string,
date-time
Registration date for the member.
Read only
Context: edit
password

string
Password for the member (never included).
Required
Context: none
roles

array
Roles assigned to the member.
Context: edit
capabilities

object
All capabilities assigned to the member.
Read only
Context: edit
extra_capabilities

object
All capabilities assigned to the member.
Read only
Context: edit
xprofile

array
Member XProfile groups and its fields.
Read only
Context: viewedit
avatar_urls (2)

object
Avatar URLs for the member (Full & Thumb sizes).
Read only
Context: embedviewedit
is_confirmed

integer
1 if the membership of this user has been confirmed, 0 otherwise.
Context: viewedit
One of: 0, 1
is_mod

integer
1 if this member is a Group moderator, 0 otherwise.
Context: viewedit
One of: 0, 1
is_admin

integer
1 if this member is a Group administrator, 0 otherwise.
Context: viewedit
One of: 0, 1
is_banned

integer
1 if this member has been banned from the Group, 0 otherwise.
Context: viewedit
One of: 0, 1
date_modified

string,
date-time
The date of the last time the membership of this user was modified, in the site’s timezone.
Context: view, edit

(2) Only if the WordPress discussion settings allow avatars.

Top ↑

List the Group Members List the Group Members

Arguments Arguments

NameTypeDescription
group_idintegerA unique numeric ID for the Group.
Required
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
pageintegerCurrent page of the collection.
Default: 1
per_pageintegerMaximum number of Group members to be returned in result set.
Default: 10
searchstringLimit results to members name matching a string.
statusstringSort the order of results by the status of the group members.
Default: last_joined
One of: last_joined, first_joined, alphabetical, group_activity (1)
rolesarrayEnsure result set includes specific Group roles.
Default: []
One or more of: adminmodmemberbanned
excludearrayEnsure result set excludes specific member IDs.
Default: []
exclude_adminsbooleanWhether results should exclude group admins and mods.
Default: true
exclude_bannedbooleanWhether results should exclude banned group members.
Default: true

(1) The group_activity status is only available if the Activity BuddyPress component is active.

Top ↑

Definition Definition

GET /buddypress/v1/groups/<group_id>/members

Top ↑

Example of use 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/4/members',
  type: 'GET',
  data: {
    context: 'view',
    exclude_admins: false
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Add a specific Member into a Group 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.

Top ↑

Arguments Arguments

NameTypeDescription
group_idintegerA unique numeric ID for the Group.
Required
user_idintegerA unique numeric ID for the Member to add to the Group.
Required
Default: the logged in user ID
contextstringScope under which the request is made; determines fields present in response.
Default: edit
One of: view, embed, edit
rolestringGroup role to assign the user to.
Default: member
One of: admin, mod, member

Top ↑

Definition Definition

POST /buddypress/v1/groups/<group_id>/members

Top ↑

Example of use 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;
} );

Top ↑

Promote or demote a specific Group Member Promote or demote a specific Group Member

Top ↑

Arguments Arguments

NameTypeDescription
group_idintegerA unique numeric ID for the Group.
Required
user_idintegerA unique numeric ID for the Group Member.
Required
contextstringScope under which the request is made; determines fields present in response.
Default: edit
One of: view, embed, edit
rolestringGroup role to assign the user to.
Default: member
One of: admin, mod, member
actionstringAction used to update a group member.
Default: promote
One of: promote, demote, ban, unban

Top ↑

Definition Definition

PUT /buddypress/v1/groups/<group_id>/members/<user_id>

Top ↑

Example of use 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;
} );

Top ↑

Remove a specific Group Member Remove a specific Group Member

Top ↑

Arguments Arguments

NameTypeDescription
group_idintegerA unique numeric ID for the Group.
Required
user_idintegerA unique numeric ID for the Group Member.
Required
contextstringScope under which the request is made; determines fields present in response.
Default: edit
One of: view, embed, edit

Top ↑

Definition Definition

DELETE /buddypress/v1/groups/<group_id>/members/<user_id>

Top ↑

Example of use 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;
} );