Skip to content

Instantly share code, notes, and snippets.

@imath
imath / bp-custom.php
Created July 12, 2019 14:17
Registering REST Fields for the BP REST API
<?php
// Registers a REST field for the Activity Endpoints.
function example_register_activity_rest_field() {
bp_rest_register_field(
'activity', // Id of the BuddyPress component the REST field is about
'example_field', // Used into the REST response/request
array(
'get_callback' => 'example_get_rest_field_callback', // The function to use to get the value of the REST Field
'update_callback' => 'example_update_rest_field_callback', // The function to use to update the value of the REST Field