Members

The BuddyPress Members endpoint extends the WordPress Users one to include specific BuddyPress data such as profile fields data (1) and use the BP_User_Query instead of the WP_User_Query to fetch the members.

(1) If the Extend profiles component is active on the website.

Schema

The schema defines all the fields that exist for a 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
An alphanumeric identifier for the member.
Context: embedviewedit
member_types

array
Member types associated with the member. See this documentation page for more information.
Read only
Context: embedviewedit
registered_date

string or null
Registration date for the member.
Read only
Context: edit
registered_date_gmt

string or null
The date the member was registered, as GMT.
Read only
Context: edit
password

string
Password for the member (never included).
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 (1)

array
Member xProfile groups and its fields.
Read only
Context: viewedit
friendship_status (2)

boolean
Whether the logged in user has a friendship relationship with the fetched user.
Read only
Context: viewedit
friendship_status_slug (2)

string
Slug of the friendship relationship status the logged in user has with the fetched user.
Read only
One of: is_friend, not_friends, pending, awaiting_response
Context: viewedit
last_activity

object
Last date the member was active on the site (object properties: timediff, date and date_gmt).
Read only
Context: viewedit
latest_update (3)

object
The content of the latest activity posted by the member (object properties: id, raw and rendered).
Read only
Context: viewedit
total_friend_count (2)

integer
Total number of friends for the member..
Read only
Context: viewedit
avatar_urls (4)

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

(2) Data is only fetched if the Friends component is active
(3) Data is only fetched if the Activity component is active
(4) Only if the WordPress discussion settings allow avatars.

Top ↑

List Members

Top ↑

Arguments

NameTypeDescription
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 members to be returned in result set.
Default: 10
searchstringLimit results to those matching a string.
excludearrayEnsure result set excludes specific IDs.
Default: []
includearrayEnsure result set include specific IDs.
Default: []
typestringShorthand for certain orderby/order combinations.
Default: newest
One of: active, newest, alphabetical, random, online, popular
user_idintegerLimit results to friends of a user.
Default: 0
user_idsarrayPass IDs of users to limit result set.
Default: []
populate_extrasbooleanWhether to fetch extra BP data about the returned members.
Default: false
member_typearrayLimit results set to certain type(s). See this documentation page for more information.
Default: []
xprofilearrayLimit results set to a certain XProfile field.
Default: []

Top ↑

Definition

GET /buddypress/v1/members

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/members',
  type: 'GET',
  data: {
    context: 'view',
    'xprofile': {
        relation: 'AND',
        args: [
            {
                field: 'Test field',
                value: 'Hello world',
                compare: '='
            }
        ]
    },
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Create a member

Top ↑

Arguments

NameTypeDescription
user_loginstringAn alphanumeric identifier for the member.
Required
passwordstringPassword for the member.
Required
emailstringThe email address for the member.
Required
namestringDisplay name for the member.
rolesarrayRoles assigned to the member.
member_typestringA comma separated list of Member Types to set for the member. See this documentation page for more information.

Top ↑

Definition

POST /buddypress/v1/members

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/members',
  type: 'POST',
  data: {
    context: 'edit',
    name: 'Test User',
    user_login: 'testuser',
    email: 'test@user.mail',
    password: 'password' // Always use strong passwords, not like this one!
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Retrieve a specific member

Top ↑

Arguments

NameTypeDescription
idintegerUnique identifier for the member.
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit
populate_extrasbooleanWhether to fetch extra BP data about the returned member.
Default: false

Top ↑

Definition

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

Top ↑

Update a specific member

Top ↑

Arguments

NameTypeDescription
idintegerUnique identifier for the user.
namestringDisplay name for the member.
rolesarrayRoles assigned to the member.
member_typestringA comma separated list of Member Types to set for the member. See this documentation page for more information.

Top ↑

Definition

PUT /buddypress/v1/members/<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/members/2',
  type: 'PUT',
  data: {
    context: 'edit',
    name: 'FirstName LastName',
    roles: 'contributor'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Delete a specific member

Top ↑

Arguments

NameTypeDescription
idintegerUnique identifier for the member.
Required
forcebooleanRequired to be true, as members do not support trashing.
reassignintegerReassign the deleted member’s posts and links to this user ID.
Required

Top ↑

Definition

DELETE /buddypress/v1/members/<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/members/2',
  type: 'DELETE',
  data: {
    context: 'edit',
    force: true,
    reassign: 1 // The User ID to reassign the deleted user's post to.
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Retrieve the logged in member

Top ↑

Arguments

NameTypeDescription
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of: view, embed, edit

Top ↑

Definition

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

Top ↑

Update the logged in member

Top ↑

Arguments

NameTypeDescription
namestringDisplay name for the member.
roles (1)arrayRoles assigned to the member.
member_typestringA comma separated list of Member Types to set for the member. See this documentation page for more information.

(1) To update roles, the logged in member must have the promote_user capability.

Top ↑

Definition

PUT /buddypress/v1/members/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/members/me',
  type: 'PUT',
  data: {
    context: 'edit',
    name: 'FirstName LastName'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Delete the logged in member

Top ↑

Arguments

NameTypeDescription
forcebooleanTrue as users do not support trashing
Required
reassignintegerReassign the deleted member’s posts and links to this user ID.
Required

Top ↑

Definition

DELETE /buddypress/v1/members/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/members/me',
  type: 'DELETE',
  data: {
    context: 'edit',
    force: true,
    reassign: 1 // The User ID to reassign the deleted user's post to.
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );