Activity
Topics
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.
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: view , edit |
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: view , edit |
user_id integer | The ID for the author of the activity. Context: view , edit |
link string, uri | The permalink to the activity on the site. Context: view , edit |
component string | The active BuddyPress component name the activity relates to. Context: view , edit One of: the active BuddyPress component names |
type string | The type of the activity (eg: activity_update ).Context: view , edit One of: the registered activity types. |
title string | The description of the activity’s type (eg: Username posted an update) Read only Context: view , edit |
content object | The raw and rendered contents of the activity.Context: view , edit |
date string or null | The date the activity was published, in the site’s timezone. Read only Context: view , edit |
date_gmt string or null | The date the activity was published, as GMT. Read only Context: view , edit |
status string | Whether the activity has been marked as spam or not. Read only Context: view , edit One of: published , spam |
array | A list of comments which are children of the activity object. Read only Context: view , edit |
comment_count integer | Total number of comments which are children of the activity object. Read only Context: view , edit |
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: view , edit |
user_avatar (1)object | Avatar URL for the author of the activity. Read only Context: view , edit |
(2) Only if the WordPress discussion settings allow avatars.
List activities
Arguments
Name | Type | Description |
---|---|---|
context | string | Scope under which the request is made; determines fields present in response. Default: view One of: view , edit |
page | integer | Current page of the collection of activities. Default: 1 |
per_page | integer | Maximum number of activities to be returned in result set. Default: 10 |
search | string | Limit results to those matching a string. |
exclude | array | Ensure result set excludes specific IDs. Default: [] |
include | array | Ensure result set includes specific IDs. Default: [] |
order | string | Order sort attribute ascending or descending. Default: desc One of: asc, desc |
after | string ,date-time | Limit result set to activities published after a given ISO8601 compliant date. |
user_id | integer | Limit result set to activities created by a specific member (ID). |
status | string | Limit result set to items with a specific status. Default: ham_only One of: ham_only, spam_only, all |
scope | string | Limit result set to items with a specific scope. Default: [] One of : just-me , friends , groups , favorites , mentions |
group_id | integer | Limit result set to activities created within a specific BuddyPress Group. |
site_id | integer | Limit result set to activities attached to a specific site. |
primary_id | integer | Limit result set to activities with a specific primary association ID. |
secondary_id | integer | Limit result set to activities with a specific secondary association ID. |
component | string | Limit result set to items with a specific active BuddyPress component. One of: the active BuddyPress components |
type | array | Limit result set to activities with one or more specific activity type. One or more of: the registered activity types |
display_comments | string | No comments by default, stream for within stream display, threaded for below each activity item.Default: '' |
Definition
GET /buddypress/v1/activity
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;
} );
Create an activity
Arguments
Name | Type | Description |
---|---|---|
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) |
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) |
user_id | integer | The ID for the author of the activity. |
link | string | The permalink to this activity on the site. |
component | string | The active BuddyPress component name the activity relates to. One of: the active BuddyPress component names |
type | string | The type of the activity (eg: activity_update ).One of: the registered activity types. |
content | string | Allowed HTML content for the activity. |
date | string ,date-time | The date the activity was published, in the site’s timezone. |
hidden | boolean | Whether the activity object should be site-wide hidden or not. |
Definition
POST /buddypress/v1/activity
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;
} );
Retrieve a specific activity
Arguments
Name | Type | Description |
---|---|---|
id | integer | A unique numeric ID for the activity. |
context | string | Scope under which the request is made; determines fields present in response. Default: view One of: view, edit |
Definition
GET /buddypress/v1/activity/<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/activity/465',
type: 'GET',
data: {
context: 'view'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
Update a specific activity
Arguments
Name | Type | Description |
---|---|---|
id | integer | A unique numeric ID for the activity. |
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) |
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) |
user_id | integer | The ID for the author of the activity. |
link | string | The permalink to this activity on the site. |
component | string | The active BuddyPress component the activity relates to. One of: the active BuddyPress components |
type | string | The type of the activity (eg: activity_update ).Required One of: the registered activity types. |
content | string | Allowed HTML content for the activity. |
date | string | The date the activity was published, in the site’s timezone. |
hidden | boolean | Whether the activity object should be site-wide hidden or not. |
Definition
PUT /buddypress/v1/activity/<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/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;
} );
Delete a specific activity
Arguments
Name | Type | Description |
---|---|---|
id | integer | A unique numeric ID for the activity. |
Definition
DELETE /buddypress/v1/activity/<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/activity/465',
type: 'DELETE',
data: {
context: 'edit'
}
} ).done( function( data ) {
return data;
} ).fail( function( error ) {
return error;
} );
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.
Arguments
Name | Type | Description |
---|---|---|
id | integer | A unique numeric ID for the activity. |
Definition
POST /buddypress/v1/activity/<id>/favorite
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;
} );