wppaste
WordPress

wp_privacy_send_personal_data_export_email( int $request_id ): true|WP_Error

Since
4.9.6
Source
wp-admin/includes/privacy-tools.php:588
Send an email to the user with a link to the personal data export file

Compatibility

WordPress
since 4.9.6
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

$request_idint
The request ID for this personal data export.

Return value

true|WP_Error
True on success or WP_Error on failure.

Performance profile

How much work a call to wp_privacy_send_personal_data_export_email() 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
Expensive

Sends mail via wp_mail().

Scaling
Constant

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

Instructions
14–149

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 164.

Plugin surface
5 hooks

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

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()called directly
  • mailsends mailwp_mail()called directly
  • querycontent queryget_post()one call below wp_privacy_send_personal_data_export_email()
  • cacheobject cachewp_cache_get()one call below wp_privacy_send_personal_data_export_email()
  • serializeserialisationmaybe_unserialize()one call below wp_privacy_send_personal_data_export_email()

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

What one call costs · 9 distinct outcomes

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

WhenInstructionsCalls it makes
always14–17wp_get_user_request(), __()
empty($request)139wp_get_user_request(), get_locale(), switch_to_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail()
!empty($request)140wp_get_user_request(), switch_to_user_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail()
empty($request)141wp_get_user_request(), get_locale(), switch_to_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
!empty($request)142wp_get_user_request(), switch_to_user_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
empty($request)146wp_get_user_request(), get_locale(), switch_to_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), __(), request()
!empty($request)147wp_get_user_request(), switch_to_user_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), __(), request()
empty($request)148wp_get_user_request(), get_locale(), switch_to_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), __(), request()
!empty($request)149wp_get_user_request(), switch_to_user_locale(), apply_filters(), get_option(), time(), date_i18n(), wp_privacy_exports_url(), get_post_meta(), get_option(), wp_specialchars_decode(), home_url(), apply_filters(), __(), sprintf(), apply_filters(), __(), apply_filters(), sanitize_url(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), __(), request()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev16414–1495
8.516414–1495
8.416414–149515 fewer instructions than PHP 8.3
8.317914–1645
8.217914–1645
8.117914–1645
7.417914–1645

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 · 5

5 hooks fire while wp_privacy_send_personal_data_export_email() runs, in this order:

  1. apply_filters( wp_privacy_export_expiration )filterline 604 (+16 into the body)

    Filters the lifetime, in seconds, of a personal data export file.

  2. apply_filters( wp_privacy_personal_data_email_to )filterline 623 (+35 into the body)

    Filters the recipient of the personal data export email notification.

  3. apply_filters( wp_privacy_personal_data_email_subject )filterline 659 (+71 into the body)

    Filters the subject of the email sent when an export request is completed.

  4. apply_filters( wp_privacy_personal_data_email_content )filterline 704 (+116 into the body)

    Filters the text of the email sent with a personal data export file.

  5. apply_filters( wp_privacy_personal_data_email_headers )filterline 737 (+149 into the body)

    Filters the headers of the email sent with a personal data export file.

Uses · 16

Show all 16

Used by · 1

Source code

<?phpfunction wp_privacy_send_personal_data_export_email( $request_id ) {	// Get the request.	$request = wp_get_user_request( $request_id ); 	if ( ! $request || 'export_personal_data' !== $request->action_name ) {		return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );	} 	// Localize message content for user; fallback to site default for visitors.	if ( ! empty( $request->user_id ) ) {		$switched_locale = switch_to_user_locale( $request->user_id );	} else {		$switched_locale = switch_to_locale( get_locale() );	} 	/** This filter is documented in wp-includes/functions.php */	$expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );	$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 	$exports_url      = wp_privacy_exports_url();	$export_file_name = get_post_meta( $request_id, '_export_file_name', true );	$export_file_url  = $exports_url . $export_file_name; 	$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );	$site_url  = home_url(); 	/**	 * Filters the recipient of the personal data export email notification.	 * Should be used with great caution to avoid sending the data export link to wrong emails.	 *	 * @since 5.3.0	 *	 * @param string          $request_email The email address of the notification recipient.	 * @param WP_User_Request $request       The request that is initiating the notification.	 */	$request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request ); 	$email_data = array(		'request'           => $request,		'expiration'        => $expiration,		'expiration_date'   => $expiration_date,		'message_recipient' => $request_email,		'export_file_url'   => $export_file_url,		'sitename'          => $site_name,		'siteurl'           => $site_url,	); 	/* translators: Personal data export notification email subject. %s: Site title. */	$subject = sprintf( __( '[%s] Personal Data Export' ), $site_name ); 	/**	 * Filters the subject of the email sent when an export request is completed.	 *	 * @since 5.3.0	 *	 * @param string $subject    The email subject.	 * @param string $sitename   The name of the site.	 * @param array  $email_data {	 *     Data relating to the account action email.	 *	 *     @type WP_User_Request $request           User request object.	 *     @type int             $expiration        The time in seconds until the export file expires.	 *     @type string          $expiration_date   The localized date and time when the export file expires.	 *     @type string          $message_recipient The address that the email will be sent to. Defaults	 *                                              to the value of `$request->email`, but can be changed	 *                                              by the `wp_privacy_personal_data_email_to` filter.	 *     @type string          $export_file_url   The export file URL.	 *     @type string          $sitename          The site name sending the mail.	 *     @type string          $siteurl           The site URL sending the mail.	 * }	 */	$subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data ); 	/* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */	$email_text = __(		'Howdy, Your request for an export of personal data has been completed. You maydownload your personal data by clicking on the link below. For privacyand security, we will automatically delete the file on ###EXPIRATION###,

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.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/privacy-tools.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.