BP_Bbp_Gdpr_Topics::topics_exporter( $email_address, int $page = 1 )

Export member created forum topics.

Description

Parameters

$email_address

(Required)

$page

(int) (Optional)

Default value: 1

Return

(array)

Source

File: bp-core/gdpr/class-bp-bbp-gdpr-topics.php

	function topics_exporter( $email_address, $page = 1 ) {
		$per_page = 500; // Limit us to avoid timing out
		$page     = (int) $page;

		$export_items = array();

		$user = get_user_by( 'email', $email_address );
		if ( false === $user ) {
			return array(
				'data' => $export_items,
				'done' => true,
			);
		}

		$topics_details = $this->get_topics( $user, $page, $per_page );
		$total          = isset( $topics_details['total'] ) ? $topics_details['total'] : 0;
		$topics         = isset( $topics_details['topics'] ) ? $topics_details['topics'] : array();

		if ( $total > 0 ) {
			foreach ( $topics as $topic ) {
				$item_id = "bbp-topic-{$topic->ID}";

				$group_id = 'bbp-topics';

				$group_label = __( 'Forum Discussions', 'buddyboss' );

				$permalink = get_permalink( $topic->ID );

				// Plugins can add as many items in the item data array as they want
				$data = array(
					array(
						'name'  => __( 'Discussion Author', 'buddyboss' ),
						'value' => $user->display_name,
					),
					array(
						'name'  => __( 'Discussion Author Email', 'buddyboss' ),
						'value' => $user->user_email,
					),
					array(
						'name'  => __( 'Discussion Title', 'buddyboss' ),
						'value' => $topic->post_title,
					),
					array(
						'name'  => __( 'Discussion Content', 'buddyboss' ),
						'value' => $topic->post_content,
					),
					array(
						'name'  => __( 'Discussion Date', 'buddyboss' ),
						'value' => $topic->post_date,
					),
					array(
						'name'  => __( 'Discussion URL', 'buddyboss' ),
						'value' => $permalink,
					),
					array(
						'name'  => __( 'Discussion Name', 'buddyboss' ),
						'value' => get_the_title( $topic->post_parent ),
					),
				);

				$export_items[] = array(
					'group_id'    => $group_id,
					'group_label' => $group_label,
					'item_id'     => $item_id,
					'data'        => $data,
				);
			}
		}

		$offset = ( $page - 1 ) * $per_page;

		// Tell core if we have more comments to work on still
		$done = $total < $offset;

		return array(
			'data' => $export_items,
			'done' => $done,
		);
	}

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.