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 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

object
Member types associated with the member. See this documentation page for more information.
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).
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
friendship_status

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

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

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

Top ↑

List Members List Members

Arguments 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: []
member_typearrayLimit results set to certain type(s). See this documentation page for more information.
Default: []
xprofilestringLimit results set to a certain XProfile field.

Top ↑

Definition Definition

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

Top ↑

Create a member Create a member

Top ↑

Arguments Arguments

NameTypeDescription
user_loginstringA numeric 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.
typesarrayA list of Member Types to set for the member. See this documentation page for more information.

Top ↑

Definition Definition

POST /buddypress/v1/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/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 Retrieve a specific member

Top ↑

Arguments 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

Top ↑

Definition Definition

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

Top ↑

Update a specific member Update a specific member

Top ↑

Arguments Arguments

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

Top ↑

Definition Definition

PUT /buddypress/v1/members/<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/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 Delete a specific member

Top ↑

Arguments 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 Definition

DELETE /buddypress/v1/members/<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/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 Retrieve the logged in member

Top ↑

Arguments Arguments

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

Top ↑

Definition Definition

GET /buddypress/members/me

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

Top ↑

Update the logged in member Update the logged in member

Top ↑

Arguments Arguments

NameTypeDescription
namestringDisplay name for the member.
roles (1)arrayRoles assigned to the member.
typesarrayA 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 Definition

PUT /buddypress/members/me

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

Top ↑

Delete the logged in member Delete the logged in member

Top ↑

Arguments 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 Definition

DELETE /buddypress/members/me

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/members/me',
  type: 'DELETE',
  context: 'edit',
  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;
} );