BP_Friendship_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-friendship-export.php

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
function get_data( $user, $page ) {
    global $wpdb, $bp;
 
    $wpdb->show_errors( false );
    $friends_table = $bp->friends->table_name;
 
    $table = "{$friends_table} item";
 
    $query_select       = "item.*";
    $query_select_count = "COUNT(item.id)";
    $query_where        = "item.initiator_user_id=%d OR item.friend_user_id=%d";
 
    $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, $user->ID );
    $query_count = "SELECT {$query_select_count} FROM {$table} WHERE {$query_where}";
    $query_count = $wpdb->prepare( $query_count, $user->ID, $user->ID );
 
    $count = (int) $wpdb->get_var( $query_count );
    $items = $wpdb->get_results( $query );
 
    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.