BP_REST_Messages_Endpoint::prepare_recipient_for_response( object $recipient, WP_REST_Request $request )
Prepares recipient data for the REST response.
Description
Parameters
- $recipient
-
(Required) The recipient object.
- $request
-
(Required) Full details about the request.
Return
(array) The recipient data for the REST response.
Source
File: bp-messages/classes/class-bp-rest-messages-endpoint.php
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 | public function prepare_recipient_for_response( $recipient , $request ) { $data = array ( 'id' => (int) $recipient ->id, 'user_id' => (int) $recipient ->user_id, 'user_link' => esc_url( bp_core_get_user_domain( $recipient ->user_id ) ), 'name' => bp_core_get_user_displayname( $recipient ->user_id ), ); // Fetch the user avatar urls (Full & thumb). if ( true === buddypress()->avatar->show_avatars ) { foreach ( array ( 'full' , 'thumb' ) as $type ) { $data [ 'user_avatars' ][ $type ] = bp_core_fetch_avatar( array ( 'item_id' => $recipient ->user_id, 'html' => false, 'type' => $type , ) ); } } $data_query = array ( 'thread_id' => (int) $recipient ->thread_id, 'unread_count' => (int) $recipient ->unread_count, 'sender_only' => (int) $recipient ->sender_only, 'is_deleted' => (int) $recipient ->is_deleted, ); if ( isset( $recipient ->is_hidden ) ) { $data_query [ 'is_hidden' ] = (int) ( isset( $recipient ->is_hidden ) ? $recipient ->is_hidden : 0 ); } $data = array_merge ( $data , $data_query ); $data [ 'current_user_permissions' ] = $this ->get_current_user_permissions( $recipient , $request ); /** * Filter a recipient value returned from the API. * * @param array $data The recipient value for the REST response. * @param object $recipient The recipient object. * @param WP_REST_Request $request Request used to generate the response. * * @since 0.1.0 */ return apply_filters( 'bp_rest_messages_prepare_recipient_value' , $data , $recipient , $request ); } |
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
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.