BP_REST_Document_Endpoint::bp_documents_get_rest_field_callback( BP_Activity_Activity $activity, string $attribute )
The function to use to get documents of the activity REST Field.
Description
Parameters
- $activity
-
(Required) Activity Array.
- $attribute
-
(Required) The REST Field key used into the REST response.
Return
(string) The value of the REST Field to include into the REST response.
Source
File: bp-document/classes/class-bp-rest-document-endpoint.php
protected function bp_documents_get_rest_field_callback( $activity, $attribute ) { $activity_id = $activity['id']; if ( empty( $activity_id ) ) { return; } $document_ids = bp_activity_get_meta( $activity_id, 'bp_document_ids', true ); $document_ids = trim( $document_ids ); $document_ids = explode( ',', $document_ids ); if ( empty( $document_ids ) ) { return; } $documents = $this->assemble_response_data( array( 'document_ids' => $document_ids ) ); if ( empty( $documents['documents'] ) ) { return; } $retval = array(); foreach ( $documents['documents'] as $document ) { $retval[] = $this->document_get_prepare_response( $document, array( 'support' => 'activity' ) ); } return $retval; }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.