BP_Activity_Export::get_data( $user,  $page, string $mode = 'erase' )

Returns the data & count of activities by page and user.

Description

Parameters

$user

(Required)

$page

(Required)

$mode

(Optional)

Default value: 'erase'

Return

(array)

Source

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

	function get_data( $user, $page, $mode = "erase" ) {
		global $wpdb;

		$wpdb->show_errors( false );

		$table              = "{$wpdb->prefix}bp_activity item";
		$query_select       = "item.*";
		$query_select_count = "COUNT(item.id)";

		$query_where = "item.user_id=%d AND item.type IN ('activity_update','activity_comment') && is_spam=0";

		$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 );

		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.