bp_xprofile_personal_data_exporter( string $email_address )

Finds and exports personal data associated with an email address from the XProfile tables.


Description Description


Parameters Parameters

$email_address

(Required) The users email address.


Top ↑

Return Return

(array) An array of personal data.


Top ↑

Source Source

File: bp-xprofile/bp-xprofile-functions.php

function bp_xprofile_personal_data_exporter( $email_address ) {
	$email_address = trim( $email_address );

	$data_to_export = array();

	$user = get_user_by( 'email', $email_address );

	if ( ! $user ) {
		return array(
			'data' => array(),
			'done' => true,
		);
	}

	$user_data_to_export = array();

	$user_profile_data = BP_XProfile_ProfileData::get_all_for_user( $user->ID );
	foreach ( $user_profile_data as $field_name => $field ) {
		// Skip non-array fields, which don't belong to XProfile.
		if ( ! is_array( $field ) ) {
			continue;
		}

		// Re-pull the data so that BuddyPress formats and sanitizes properly.
		$value = xprofile_get_field_data( $field['field_id'], $user->ID, 'comma' );
		$user_data_to_export[] = array(
			'name'  => $field_name,
			'value' => $value,
		);
	}

	$data_to_export[] = array(
		'group_id'    => 'bp_xprofile',
		'group_label' => __( 'Extended Profile Data', 'buddypress' ),
		'item_id'     => "bp-xprofile-{$user->ID}",
		'data'        => $user_data_to_export,
	);

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

Top ↑

Changelog Changelog

Changelog
Version Description
4.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.