Sitewide Notices

The Sitewide Notices feature allows to send notices to the whole site. This feature is currently part of the Private Messages Component.

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

Schema

The schema defines all the fields that exist for a Siteweide Notice object.

id

integer
A unique numeric ID for the sitewide notice.
Read only
Context: viewedit
subject

object
The raw and rendered contents of the sitewide notice subject.
Context: viewedit
message

object
The raw and rendered contents of the sitewide notice.
Required
Context: viewedit
date

string or null
The date of the sitewide notice, in the site’s timezone.
Read only
Context: viewedit
date_gmt

string or null
The date of the sitewide notice, as GMT.
Read only
Context: viewedit
is_active

bool
Whether this sitewide notice is active or not.
Read only
Context: viewedit

Top ↑

List Sitewide Notices

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 sitewide notices collection.
Minimum: 1
Default: 1
per_pageintegerMaximum number of sitewide notices to be returned in result set.
Minimum: 1
Default: 10
Maximum: 100
searchstringLimit results to those matching a string.

Top ↑

Definition

GET /buddypress/v1/sitewide-notices

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

Top ↑

Retrieve a specific Sitewide Notice

Top ↑

Arguments

NameTypeDescription
idintegerID of a Sitewide Notice.
Required

Top ↑

Definition

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

Top ↑

Update a specific Sitewide Notice

Top ↑

Arguments

NameTypeDescription
idintegerID of the Sitewide Notice.
Required
subjectstringSubject of the Sitewide Notice.
messagestringContent of the Sitewide Notice.
is_activeboolThe status of the Sitewide Notice (active or not).

Top ↑

Description

PUT /buddypress/v1/sitewide-notices/<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/sitewide-notices/5',
  type: 'PUT',
  data: {
    context: 'edit',
    subject: 'a new subject for this sitewide notice'
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );

Top ↑

Delete a specific Sitewide Notice

Top ↑

Arguments

NameDescription
idID of the Sitewide Notice.
Required

Top ↑

Definition

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

Top ↑

Dismiss currently active notice for the current user

When a user requests to dismiss the current active sitewide notice, the notice is dimissed.

Warning: If the user is not logged in or if there is no active notice available, the REST response will be an error object.

Top ↑

Definition

PUT /buddypress/v1/sitewide-notices/dismiss

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/sitewide-notices/dismiss',
  type: 'PUT',
  data: {
    context: 'edit',
  }
} ).done( function( data ) {
  return data;
} ).fail( function( error ) {
  return error;
} );