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

Export member extended profile fields.

Description

Parameters

$user

(Required)

$page

(Required)

$email_address

(bool) (Optional)

Default value: false

Return

(array)

Source

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

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

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

		$export_items = array();

		/**
		 * Cover Photo & Avatar
		 */
		if ( function_exists( 'bp_core_fetch_avatar' ) ) {
			$avatar = bp_core_fetch_avatar( array(
				'item_id' => $user->ID,
				'object'  => 'user',
				'type'    => 'full',
				'html'    => false,
			) );
		}

		if ( function_exists( 'bp_attachments_get_attachment' ) ) {
			$cover_photo = bp_attachments_get_attachment( 'url',
				array(
					'item_id'    => $user->ID,
					'type'       => 'cover-image',
					'object_dir' => 'members',
				) );
		}

		if ( empty( $avatar ) || ! $avatar ) {
			$avatar = __( 'N/A', 'buddyboss' );
		}
		if ( empty( $cover_photo ) || ! $cover_photo ) {
			$cover_photo = __( 'N/A', 'buddyboss' );
		}

		$data[] = array( 'name' => __( 'Avatar', 'buddyboss' ), 'value' => $avatar );
		$data[] = array( 'name' => __( 'Cover Photo', 'buddyboss' ), 'value' => $cover_photo );

		$export_items[] = array(
			'group_id'    => "{$this->exporter_name}-cover-avatar",
			'group_label' => __( 'User Profile - Avatar & Cover Photos', 'buddyboss' ),
			'item_id'     => "{$this->exporter_name}-assets-{$user->ID}",
			'data'        => $data,
		);


		/**
		 * Xprofile Fields
		 */

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

		foreach ( $data_items['items'] as $xgroup => $items ) {

			$group_id    = $xgroup;
			$group_label = __( "User Profile - {$xgroup}", 'buddyboss' );
			$item_id     = "{$this->exporter_name}-{$group_id}";

			$data = array();

			foreach ( $items as $item ) {
				$val = trim( $item['value'] );
				if ( empty( $val ) ) {
					$val = __( 'N/A', 'buddyboss' );
				}
				$data[] = array( 'name' => $item['name'], 'value' => $val );
			}

			$data = apply_filters( 'buddyboss_bp_gdpr_xprofile_after_data_prepare', $data, $items, $data_items );

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

		}


		$done = true; // on this we are processing everything at once.

		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.