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

Export member friendships.

Description

Parameters

$user

(Required)

$page

(Required)

$email_address

(Optional)

Default value: false

Return

(array)

Source

File: bp-core/gdpr/class-bp-friendship-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_friends';
			$group_label = __( 'Connections', 'buddyboss' );
			$item_id     = "{$this->exporter_name}-{$group_id}-{$item->id}";

			if ( $item->initiator_user_id == $user->ID ) {
				$friend_user_id = $item->friend_user_id;
				$is_initiator   = true;
			} else {
				$friend_user_id = $item->initiator_user_id;
				$is_initiator   = false;
			}

			if ( $item->is_confirmed == "0" && $is_initiator ) {
				$group_id    .= '_pending_sent';
				$group_label = __( 'Pending Sent Connection Requests', 'buddyboss' );
			}

			if ( $item->is_confirmed == "0" && ! $is_initiator ) {
				$group_id    .= '_pending_received';
				$group_label = __( 'Pending Received Connection Requests', 'buddyboss' );
			}

			$friend_user = get_userdata( $friend_user_id );

			$data = array(
				array(
					'name' => __( 'Connection Name', 'buddyboss' ),
					'value' => $friend_user->display_name
				),
				array(
					'name' => __( 'Sent Created (GMT)', 'buddyboss' ),
					'value' => $item->date_created
				),
			);

			if ( $item->is_confirmed == '1' ) {
				$is_initiator_value = ( ( $is_initiator ) ? __( 'Yes', 'buddyboss' ) : __( 'No', 'buddyboss' ) );
				$data[]             = array(
					'name'  => __( 'Request Initiator', 'buddyboss' ),
					'value' => $is_initiator_value,
				);
			}

			$data = apply_filters( 'buddyboss_bp_gdpr_friendship_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.