BP_Message_Export::messages_recipients( $items )
Merge recipients into items.
Description
Parameters
- $items
-
(Required)
Return
(array)
Source
File: bp-core/gdpr/class-bp-message-export.php
function messages_recipients( $items ) {
global $wpdb, $bp;
$table = "{$bp->messages->global_tables["table_name_recipients"]}";
$thread_ids = array();
foreach ( $items as $item ) {
$thread_ids[ $item->thread_id ] = $item->thread_id;
}
if ( empty( $thread_ids ) ) {
return array();
}
$ids_in = array_fill( 0, count( $thread_ids ), '%s' );
$ids_in = join( ',', $ids_in );
$get_results = $wpdb->get_results( $wpdb->prepare( "SELECT *FROM {$table} WHERE thread_id IN ({$ids_in})",
$thread_ids ) );
$thread_recipients = array();
foreach ( $get_results as $result ) {
if ( ! isset( $thread_recipients[ $result->thread_id ] ) || ! is_array( $thread_recipients[ $result->thread_id ] ) ) {
$thread_recipients[ $result->thread_id ] = array();
}
if ( ! isset( $thread_recipients[ $result->thread_id ][ $result->user_id ] ) ) {
$thread_recipients[ $result->thread_id ][ $result->user_id ] = get_userdata( $result->user_id );
}
}
foreach ( $items as $item_key => $item ) {
if ( ! isset( $thread_recipients[ $item->thread_id ] ) ) {
$thread_recipients[ $item->thread_id ] = array();
}
$item->recipients = $thread_recipients[ $item->thread_id ];
}
return $items;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.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.