BP_Group_Export::merge_metas( $items )
Fetch all metas and merge into items.
Description
Parameters
- $items
-
(Required)
Return
(array)
Source
File: bp-core/gdpr/class-bp-group-export.php
function merge_metas( $items ) { global $wpdb, $bp; $group_meta_table = $bp->groups->global_tables["table_name_groupmeta"]; // get all ids $group_ids = array(); foreach ( $items as $item ) { $group_ids[] = $item->id; } if ( empty( $group_ids ) ) { return array(); } $ids_in = array_fill( 0, count( $group_ids ), '%s' ); $ids_in = join( ',', $ids_in ); $query = $wpdb->prepare( "SELECT *FROM {$group_meta_table} WHERE group_id in ({$ids_in})", $group_ids ); $results = $wpdb->get_results( $query ); $metas_by_group = array(); foreach ( $results as $result ) { $metas_by_group[ $result->group_id ][] = $result; } // merge into items foreach ( $items as $item_key => $item ) { $items[ $item_key ]->metas = ( isset( $metas_by_group[ $item->id ] ) ) ? $metas_by_group[ $item->id ] : array(); } 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.