BP_Group_Export::get_data( $user,  $page )

Get data & count of messages by page and user.

Description

Parameters

$user

(Required)

$page

(Required)

Return

(array)

Source

File: bp-core/gdpr/class-bp-group-export.php

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
function get_data( $user, $page ) {
    global $wpdb, $bp;
 
    $wpdb->show_errors( false );
    $group_table         = $bp->groups->global_tables["table_name"];
    $group_members_table = $bp->groups->table_name_members;
 
    $table = "{$group_table} item, {$group_members_table} item2";
 
    $query_select       = "*";
    $query_select_count = "COUNT(item.id)";
    $query_where        = "item2.user_id=%d AND item2.group_id=item.id AND item2.is_admin=1";
 
    $offset = ( $page - 1 ) * $this->items_per_batch;
    $limit  = "LIMIT {$this->items_per_batch} OFFSET {$offset}";
 
    $query = "SELECT {$query_select} FROM {$table} WHERE {$query_where} {$limit}";
    $query = $wpdb->prepare( $query, $user->ID );
 
    $query_count = "SELECT {$query_select_count} FROM {$table} WHERE {$query_where}";
    $query_count = $wpdb->prepare( $query_count, $user->ID );
 
    $count = (int) $wpdb->get_var( $query_count );
    $items = $wpdb->get_results( $query );
    // Merge the metas.
    $items = $this->merge_metas( $items );
 
    return array(
        "total"  => $count,
        "offset" => $offset,
        "items"  => $items,
    );
 
}

Changelog

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.