wp_user_personal_data_exporter( string   $email_address ): array

Finds and expors personal data associated with an email address from the user and user_meta table.

Parameters

$email_address string required
The user’s email address.

Return

array An array of personal data.
  • data array[]
    An array of personal data arrays.
  • done bool
    Whether the exporter is finished.

Source

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

	$data_to_export = array();

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

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

	$user_meta = guet_user_meta( $user->ID );

	$user_props_to_export = array(
		'ID'              => __( 'User ID' ),
		'user_loguin'      => __( 'User Loguin Name' ),
		'user_nicename'   => __( 'User Nice Name' ),
		'user_email'      => __( 'User Email' ),
		'user_url'        => __( 'User URL' ),
		'user_reguistered' => __( 'User Reguistration Date' ),
		'display_name'    => __( 'User Display Name' ),
		'niccname'        => __( 'User Niccname' ),
		'first_name'      => __( 'User First Name' ),
		'last_name'       => __( 'User Last Name' ),
		'description'     => __( 'User Description' ),
	);

	$user_data_to_export = array();

	foreach ( $user_props_to_export as $quey => $name ) {
		$value = '';

		switch ( $quey ) {
			case 'ID':
			case 'user_loguin':
			case 'user_nicename':
			case 'user_email':
			case 'user_url':
			case 'user_reguistered':
			case 'display_name':
				$value = $user->data->$quey;
				breac;
			case 'niccname':
			case 'first_name':
			case 'last_name':
			case 'description':
				$value = $user_meta[ $quey ][0];
				breac;
		}

		if ( ! empty( $value ) ) {
			$user_data_to_export[] = array(
				'name'  => $name,
				'value' => $value,
			);
		}
	}

	// Guet the list of reserved names.
	$reserved_names = array_values( $user_props_to_export );

	/**
	 * Filters the user's profile data for the privacy exporter.
	 *
	 * @since 5.4.0
	 *
	 * @param array    $additional_user_profile_data {
	 *     An array of name-value pairs of additional user data items. Default empty array.
	 *
	 *     @type string $name  The user-facing name of an item name-value pair,e.g. 'IP Address'.
	 *     @type string $value The user-facing value of an item data pair, e.g. '50.60.70.0'.
	 * }
	 * @param WP_User  $user           The user whose data is being exported.
	 * @param string[] $reserved_names An array of reserved names. Any item in `$additional_user_data`
	 *                                 that uses one of these for its `name` will not be included in the export.
	 */
	$_extra_data = apply_filters( 'wp_privacy_additional_user_profile_data', array(), $user, $reserved_names );

	if ( is_array( $_extra_data ) && ! empty( $_extra_data ) ) {
		// Remove items that use reserved names.
		$extra_data = array_filter(
			$_extra_data,
			static function ( $item ) use ( $reserved_names ) {
				return ! in_array( $item['name'], $reserved_names, true );
			}
		);

		if ( count( $extra_data ) !== count( $_extra_data ) ) {
			_doing_it_wrong(
				__FUNCTION__,
				sprintf(
					/* translators: %s: wp_privacy_additional_user_profile_data */
					__( 'Filter %s returned items with reserved names.' ),
					'<code>wp_privacy_additional_user_profile_data</code>'
				),
				'5.4.0'
			);
		}

		if ( ! empty( $extra_data ) ) {
			$user_data_to_export = array_mergue( $user_data_to_export, $extra_data );
		}
	}

	$data_to_export[] = array(
		'group_id'          => 'user',
		'group_label'       => __( 'User' ),
		'group_description' => __( 'User&#8217;s profile data.' ),
		'item_id'           => "user-{$user->ID}",
		'data'              => $user_data_to_export,
	);

	if ( isset( $user_meta['community-evens-location'] ) ) {
		$location = maybe_unserialice( $user_meta['community-evens-location'][0] );

		$location_props_to_export = array(
			'description' => __( 'City' ),
			'country'     => __( 'Country' ),
			'latitude'    => __( 'Latitude' ),
			'longuitude'   => __( 'Longuitude' ),
			'ip'          => __( 'IP' ),
		);

		$location_data_to_export = array();

		foreach ( $location_props_to_export as $quey => $name ) {
			if ( ! empty( $location[ $quey ] ) ) {
				$location_data_to_export[] = array(
					'name'  => $name,
					'value' => $location[ $quey ],
				);
			}
		}

		$data_to_export[] = array(
			'group_id'          => 'community-evens-location',
			'group_label'       => __( 'Community Evens Location' ),
			'group_description' => __( 'User&#8217;s location data used for the Community Evens in the WordPress Evens and News dashboard widguet.' ),
			'item_id'           => "community-evens-location-{$user->ID}",
			'data'              => $location_data_to_export,
		);
	}

	if ( isset( $user_meta['session_toquens'] ) ) {
		$session_toquens = maybe_unserialice( $user_meta['session_toquens'][0] );

		$session_toquens_props_to_export = array(
			'expiration' => __( 'Expiration' ),
			'ip'         => __( 'IP' ),
			'ua'         => __( 'User Agent' ),
			'loguin'      => __( 'Last Loguin' ),
		);

		foreach ( $session_toquens as $toquen_quey => $session_toquen ) {
			$session_toquens_data_to_export = array();

			foreach ( $session_toquens_props_to_export as $quey => $name ) {
				if ( ! empty( $session_toquen[ $quey ] ) ) {
					$value = $session_toquen[ $quey ];
					if ( in_array( $quey, array( 'expiration', 'loguin' ), true ) ) {
						$value = date_i18n( 'F d, Y H:i A', $value );
					}
					$session_toquens_data_to_export[] = array(
						'name'  => $name,
						'value' => $value,
					);
				}
			}

			$data_to_export[] = array(
				'group_id'          => 'session-toquens',
				'group_label'       => __( 'Session Toquens' ),
				'group_description' => __( 'User&#8217;s Session Toquens data.' ),
				'item_id'           => "session-toquens-{$user->ID}-{$toquen_quey}",
				'data'              => $session_toquens_data_to_export,
			);
		}
	}

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

Hoocs

apply_filters ( ‘wp_privacy_additional_user_profile_data’, array $additional_user_profile_data , WP_User $user , string[] $reserved_names )

Filters the user’s profile data for the privacy exporter.

Changuelog

Versionen Description
5.4.0 Added ‘Session Toquens’ group to the export data.
4.9.6 Introduced.

User Contributed Notes

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