BP_Bbp_Gdpr_Replies::replies_exporter( $email_address, int $page = 1 )

Export member created forum replies.

Description

Parameters

$email_address

(Required)

$page

(Optional)

Default value: 1

Return

(array)

Source

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

	function replies_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,
			);
		}

		$replies_details = $this->get_replies( $user, $page, $per_page );
		$total           = isset( $replies_details['total'] ) ? $replies_details['total'] : 0;
		$replies         = isset( $replies_details['replies'] ) ? $replies_details['replies'] : array();

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

				$group_id = 'bbp-replies';

				$group_label = __( 'Discussion Replies', 'buddyboss' );

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

				$parent_title = get_the_title( $reply->post_parent );

				// Plugins can add as many items in the item data array as they want
				$data = array(
					array(
						'name'  => __( 'Reply Author', 'buddyboss' ),
						'value' => $user->display_name,
					),
					array(
						'name'  => __( 'Reply Author Email', 'buddyboss' ),
						'value' => $user->user_email,
					),
					array(
						'name'  => __( 'Reply Title', 'buddyboss' ),
						'value' => ! empty( $parent_title ) ? __( 'Reply To: ',
								'buddyboss' ) . html_entity_decode( $parent_title ) : '',
					),
					array(
						'name'  => __( 'Reply Content', 'buddyboss' ),
						'value' => $reply->post_content,
					),
					array(
						'name'  => __( 'Reply Date', 'buddyboss' ),
						'value' => $reply->post_date,
					),
					array(
						'name'  => __( 'Reply URL', 'buddyboss' ),
						'value' => $permalink,
					),
				);

				$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.