BP_Message_Export::process_data( $user,  $page, bool $email_address = false )

Export member messages.

Description

Parameters

$user

(Required)

$page

(Required)

$email_address

(bool) (Optional)

Default value: false

Return

(array)

Source

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

	function process_data( $user, $page, $email_address = false ) {

		if ( ! $user || is_wp_error( $user ) ) {
			return $this->response( array(), true );
		}

		$export_items = array();

		$data_items = $this->get_data( $user, $page );

		foreach ( $data_items['items'] as $item ) {

			$group_id    = "bp_messages";
			$group_label = __( 'Message Threads & Replies', 'buddyboss' );
			$item_id     = "{$this->exporter_name}-{$group_id}-{$item->id}";

			$permalink = bp_get_message_thread_view_link( $item->thread_id, $user->ID );

			// recipients
			$recipients = array();
			if ( ! is_array( $item->recipients ) ) {
				$item->recipients = array();
			}
			foreach ( $item->recipients as $r_user ) {
				if ( ! empty( $r_user ) ) {
					$name = $r_user->display_name;
					if ( empty( $r_user->display_name ) ) {
						$name = $r_user->user_login;
					}
					$recipients[] = $name;
				}
			}
			$recipients = implode( ", ", $recipients );

			$recipients = apply_filters( 'buddyboss_bp_gdpr_bp_message_item_recipients', $recipients, $item, $data_items );

			$data = array(
				array(
					'name' => __( 'Message Subject', 'buddyboss' ),
					'value' => $item->subject
				),
				array(
					'name' => __( 'Message Content', 'buddyboss' ),
					'value' => $item->message
				),
				array(
					'name' => __( 'Created Date (GMT)', 'buddyboss' ),
					'value' => $item->date_sent
				),
				array(
					'name' => __( 'Message Recipients', 'buddyboss' ),
					'value' => $recipients
				),
				array(
					'name' => __( 'Thread URL', 'buddyboss' ),
					'value' => $permalink
				),
			);

			$data = apply_filters( 'buddyboss_bp_gdpr_message_after_data_prepare', $data, $item, $data_items );

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

		}

		$done = $data_items["total"] < $data_items["offset"];

		return $this->response( $export_items, $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.