从user和user_meta表中查找并导出与电子邮件地址关联的个人数据。

原型

wp_user_personal_data_exporter( string $email_address )

参数

$email_address (string) (Required) 用户的电子邮件地址。

返回值

(array)  一系列个人数据。

源文件

路径:wp-includes/user.php

<?php
...
function wp_user_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_meta = get_user_meta( $user->ID );
	$user_prop_to_export = array(
		'ID'              => __( 'User ID' ),
		'user_login'      => __( 'User Login Name' ),
		'user_nicename'   => __( 'User Nice Name' ),
		'user_email'      => __( 'User Email' ),
		'user_url'        => __( 'User URL' ),
		'user_registered' => __( 'User Registration Date' ),
		'display_name'    => __( 'User Display Name' ),
		'nickname'        => __( 'User Nickname' ),
		'first_name'      => __( 'User First Name' ),
		'last_name'       => __( 'User Last Name' ),
		'description'     => __( 'User Description' ),
	);
	$user_data_to_export = array();
	foreach ( $user_prop_to_export as $key => $name ) {
		$value = '';
		switch ( $key ) {
			case 'ID':
			case 'user_login':
			case 'user_nicename':
			case 'user_email':
			case 'user_url':
			case 'user_registered':
			case 'display_name':
				$value = $user->data->$key;
				break;
			case 'nickname':
			case 'first_name':
			case 'last_name':
			case 'description':
				$value = $user_meta[ $key ][0];
				break;
		}
		if ( ! empty( $value ) ) {
			$user_data_to_export[] = array(
				'name'  => $name,
				'value' => $value,
			);
		}
	}
	$data_to_export[] = array(
		'group_id'    => 'user',
		'group_label' => __( 'User' ),
		'item_id'     => "user-{$user->ID}",
		'data'        => $user_data_to_export,
	);
	return array(
		'data' => $data_to_export,
		'done' => true,
	);
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_user_personal_data_exporter/