Activity

BuddyPress activities inform about actions and interactions of the community site’s members. Members can share public announcements and react about these by commenting or favoriting them. Activities also log events generated by the other BuddyPress components, for instance, when two users become friends.

Note: The Activity component is an optional one. This means the activity endpoints will only be available if the component is active on the community site.

Schema

The schema defines all the fields that exist for an activity object.

id

integer
A unique numeric ID for the activity.
Read only
Context: viewedit
primary_item_id

integer
The ID of another BuddyPress object primarily associated with the activity.
(In case of an activity comment, the root activity ID of the thread)
Context: view, edit
secondary_item_id

integer
The ID of some BuddyPress object (most of the time relative to the primary_item_id) also associated with the activity.
(In case of an activity comment, the immediate parent activity ID of the thread)
Context: viewedit
user_id

integer
The ID for the author of the activity.
Context: viewedit
link

string,
uri
The permalink to the activity on the site.
Context: viewedit
component

string
The active BuddyPress component name the activity relates to.
Context: viewedit
One of: the active BuddyPress component names
type

string
The type of the activity (eg: activity_update).
Context: viewedit
One of: the registered activity types.
title

string
The description of the activity’s type (eg: Username posted an update)
Read only
Context: viewedit
content

object
The raw and rendered contents of the activity.
Context: viewedit
date

string or null
The date the activity was published, in the site’s timezone.
Read only
Context: viewedit
date_gmt

string or null
The date the activity was published, as GMT.
Read only
Context: viewedit
status

string
Whether the activity has been marked as spam or not.
Read only
Context: viewedit
One of: published, spam
comments

array
A list of comments which are children of the activity object.
Read only
Context: viewedit
comment_count

integer
Total number of comments which are children of the activity object.
Read only
Context: viewedit
hidden

boolean
Whether the activity is site-wide hidden or not.
Context: edit
favorited

boolean
Whether the activity has been favorited by the logged in user.
Read only
Context: viewedit
user_avatar (1)

object
Avatar URL for the author of the activity.
Read only
Context: viewedit

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

Top ↑

List activities

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 of activities.
Default: 1
per_pageintegerMaximum number of activities 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 includes specific IDs.
Default: []
orderstringOrder sort attribute ascending or descending.
Default: desc
One of: asc, desc
afterstring,
date-time
Limit result set to activities published after a given ISO8601 compliant date.
user_idintegerLimit result set to activities created by a specific member (ID).
statusstringLimit result set to items with a specific status.
Default: ham_only
One of: ham_only, spam_only, all
scopestringLimit result set to items with a specific scope.
Default: []
One of : just-me, friends, groups, favorites, mentions
group_idintegerLimit result set to activities created within a specific BuddyPress Group.
site_idintegerLimit result set to activities attached to a specific site.
primary_idintegerLimit result set to activities with a specific primary association ID.
secondary_idintegerLimit result set to activities with a specific secondary association ID.
componentstringLimit result set to items with a specific active BuddyPress component.
One of: the active BuddyPress components
typearrayLimit result set to activities with one or more specific activity type.
One or more of: the registered activity types
display_commentsstringNo comments by default, stream for within stream display, threaded for below each activity item.
Default: ''

Top ↑

Definition

GET /buddypress/v1/activity

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

Top ↑

Create an activity

Top ↑

Arguments

NameTypeDescription
primary_item_idintegerThe ID of another BuddyPress object primarily associated with the activity.
(In case of an activity comment, the root activity ID of the thread)
secondary_item_idintegerThe ID of some BuddyPress object (most of the time relative to the primary_item_id) also associated with the activity.
(In case of an activity comment, the immediate parent activity ID of the thread)
user_idintegerThe ID for the author of the activity.
linkstringThe permalink to this activity on the site.
componentstringThe active BuddyPress component name the activity relates to.
One of: the active BuddyPress component names
typestringThe type of the activity (eg: activity_update).
One of: the registered activity types.
contentstringAllowed HTML content for the activity.
datestring,
date-time
The date the activity was published, in the site’s timezone.
hiddenbooleanWhether the activity object should be site-wide hidden or not.

Top ↑

Definition

POST /buddypress/v1/activity

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/activity',
  type: 'POST',
  data: {
    context: 'edit',
    user_id: 1,
    component: 'activity',
    type: 'activity_update',
    content: 'Hello <b>BuddyPress</b>'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Retrieve a specific activity

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the activity.
contextstringScope under which the request is made; determines fields present in response.
Default: view
One of: view, edit

Top ↑

Definition

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

Top ↑

Update a specific activity

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the activity.
primary_item_idintegerThe ID of another BuddyPress object primarily associated with the activity.
(In case of an activity comment, the root activity ID of the thread)
secondary_item_idintegerThe ID of some BuddyPress object (most of the time relative to the primary_item_id) also associated with the activity.
(In case of an activity comment, the immediate parent activity ID of the thread)
user_idintegerThe ID for the author of the activity.
linkstringThe permalink to this activity on the site.
componentstringThe active BuddyPress component the activity relates to.
One of: the active BuddyPress components
typestringThe type of the activity (eg: activity_update).
Required
One of: the registered activity types.
contentstringAllowed HTML content for the activity.
datestringThe date the activity was published, in the site’s timezone.
hiddenbooleanWhether the activity object should be site-wide hidden or not.

Top ↑

Definition

PUT /buddypress/v1/activity/<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/activity/465',
  type: 'PUT',
  data: {
    context: 'edit',
    type: 'activity_update',
    content: 'Hello <em>BuddyPress</em>'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Delete a specific activity

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the activity.

Top ↑

Definition

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

Top ↑

Add or remove a specific activity from favorited activities

NB: the same endpoint is used to favorite and unfavorite an activity. In case the activity is already favorited, it will remove this activity from favorite activities.

Top ↑

Arguments

NameTypeDescription
idintegerA unique numeric ID for the activity.

Top ↑

Definition

POST /buddypress/v1/activity/<id>/favorite

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/activity/461/favorite',
  type: 'POST',
  data: {
    context: 'edit'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );