wppaste
WordPress

wp_user_personal_data_exporter( string $email_address ): array

Since
4.9.6, 5.4.0, 5.4.0
Source
wp-includes/user.php:4049
Finds and exports personal data associated with an email address from the user and user_meta table.

Compatibility

WordPress
since 5.4.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$email_addressstring
The user's email address.

Return value

array
An array of personal data.
  • $dataarray[]

    An array of personal data arrays.
  • $donebool

    Whether the exporter is finished.

Performance profile

How much work a call to wp_user_personal_data_exporter() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_user_by().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
7

Executed per call on PHP 8.5. The body compiles to 304.

Plugin surface
1 hook

Third-party callbacks on 'wp_privacy_additional_user_profile_data' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • querycontent queryget_user_by()called directly
  • hookthird-party callbacksapply_filters()called directly
  • serializeserialisationmaybe_unserialize()called directly

Further down the call graph this can also reach option, cache and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_user_personal_data_exporter() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always7none

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev304731
8.5304731
8.43047315 fewer instructions than PHP 8.3
8.33091031
8.230910311 more instruction than PHP 8.1
8.13081031
7.43081031

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while wp_user_personal_data_exporter() runs, in this order:

  1. apply_filters( wp_privacy_additional_user_profile_data )filterline 4128 (+79 into the body)

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

Uses · 7

Source code

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_props_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_props_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,			);		}	} 	// Get 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 );

Changelog

Introduced in 4.9.6. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.4.0
Added 'Session Tokens' group to the export data.from the docblock
5.4.0
Added 'Community Events Location' group to the export data.from the docblock
4.9.6
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/user.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.