wppaste
WordPress

_wp_privacy_send_erasure_fulfillment_notification( int $request_id )

Since
4.9.6
Source
wp-includes/user.php:4468
Notifies the user when their erasure request is fulfilled.

Description

Without this, the user would never know if their data was actually erased.

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 privacy request post ID associated with this request.

Performance profile

How much work a call to _wp_privacy_send_erasure_fulfillment_notification() 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
8–167

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

Plugin surface
7 hooks

Third-party callbacks on 'user_erasure_fulfillment_email_to', 'user_erasure_complete_email_subject', 'user_erasure_fulfillment_email_subject' 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

  • 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_erasure_fulfillment_notification()
  • cacheobject cachewp_cache_get()one call below _wp_privacy_send_erasure_fulfillment_notification()
  • serializeserialisationmaybe_unserialize()one call below _wp_privacy_send_erasure_fulfillment_notification()

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 · 18 distinct outcomes

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

WhenInstructionsCalls it makes
always8–11wp_get_user_request()
$request instanceof18wp_get_user_request(), get_post_meta()
$request instanceof && empty($request) && empty($email_data)155wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail()
$request instanceof && !empty($request) && empty($email_data)156wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail()
$request instanceof && empty($request) && empty($email_data)157wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
$request instanceof && !empty($request) && empty($email_data)158wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
$request instanceof && empty($request) && !empty($email_data)159wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail()
$request instanceof && !empty($request) && !empty($email_data)160wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail()
$request instanceof && empty($request) && empty($email_data)160wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), update_post_meta()
$request instanceof && !empty($request) && empty($email_data)161wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), update_post_meta()
$request instanceof && empty($request) && !empty($email_data)161wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
$request instanceof && !empty($request) && !empty($email_data)162wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale()
6 further outcomes, up to 167 instructions
$request instanceof && empty($request) && empty($email_data)162wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), update_post_meta()
$request instanceof && !empty($request) && empty($email_data)163wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), update_post_meta()
$request instanceof && empty($request) && !empty($email_data)164wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), update_post_meta()
$request instanceof && !empty($request) && !empty($email_data)165wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), update_post_meta()
$request instanceof && empty($request) && !empty($email_data)166wp_get_user_request(), get_post_meta(), get_locale(), switch_to_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), update_post_meta()
$request instanceof && !empty($request) && !empty($email_data)167wp_get_user_request(), get_post_meta(), switch_to_user_locale(), apply_filters(), get_privacy_policy_url(), get_option(), wp_specialchars_decode(), home_url(), __(), sprintf(), apply_filters(), __(), __(), __(), sprintf(), apply_filters(), sanitize_url(), apply_filters(), wp_mail(), restore_previous_locale(), update_post_meta()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1758–1677
8.51758–1677
8.41758–16779 fewer instructions than PHP 8.3
8.31848–1767
8.21848–1767
8.11848–1767
7.41848–1767

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

7 hooks fire while _wp_privacy_send_erasure_fulfillment_notification() runs, in this order:

  1. apply_filters( user_erasure_fulfillment_email_to )filterline 4496 (+28 into the body)

    Filters the recipient of the data erasure fulfillment notification.

  2. do_action( user_erasure_complete_email_subject )filter_deprecatedline 4532 (+64 into the body)

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

  3. apply_filters( user_erasure_fulfillment_email_subject )filterline 4558 (+90 into the body)

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

  4. do_action( user_confirmed_action_email_content )filter_deprecatedline 4620 (+152 into the body)

    Filters the body of the user request confirmation email.

  5. apply_filters( user_erasure_fulfillment_email_content )filterline 4659 (+191 into the body)

    Filters the body of the data erasure fulfillment notification.

  6. do_action( user_erasure_complete_email_headers )filter_deprecatedline 4689 (+221 into the body)

    Filters the headers of the data erasure fulfillment notification.

  7. apply_filters( user_erasure_fulfillment_email_headers )filterline 4717 (+249 into the body)

    Filters the headers of the data erasure fulfillment notification.

Uses · 16

Show all 16

Source code

function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) {	$request = wp_get_user_request( $request_id ); 	if ( ! ( $request instanceof WP_User_Request ) || 'request-completed' !== $request->status ) {		return;	} 	$already_notified = (bool) get_post_meta( $request_id, '_wp_user_notified', true ); 	if ( $already_notified ) {		return;	} 	// 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() );	} 	/**	 * Filters the recipient of the data erasure fulfillment notification.	 *	 * @since 4.9.6	 *	 * @param string          $user_email The email address of the notification recipient.	 * @param WP_User_Request $request    The request that is initiating the notification.	 */	$user_email = apply_filters( 'user_erasure_fulfillment_email_to', $request->email, $request ); 	$email_data = array(		'request'            => $request,		'message_recipient'  => $user_email,		'privacy_policy_url' => get_privacy_policy_url(),		'sitename'           => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),		'siteurl'            => home_url(),	); 	$subject = sprintf(		/* translators: Erasure request fulfilled notification email subject. %s: Site title. */		__( '[%s] Erasure Request Fulfilled' ),		$email_data['sitename']	); 	/**	 * Filters the subject of the email sent when an erasure request is completed.	 *	 * @since 4.9.8	 * @deprecated 5.8.0 Use {@see 'user_erasure_fulfillment_email_subject'} instead.	 *	 * @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 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 `user_erasure_fulfillment_email_to` filter.	 *     @type string          $privacy_policy_url Privacy policy URL.	 *     @type string          $sitename           The site name sending the mail.	 *     @type string          $siteurl            The site URL sending the mail.	 * }	 */	$subject = apply_filters_deprecated(		'user_erasure_complete_email_subject',		array( $subject, $email_data['sitename'], $email_data ),		'5.8.0',		'user_erasure_fulfillment_email_subject'	); 	/**	 * Filters the subject of the email sent when an erasure request is completed.	 *	 * @since 5.8.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.

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 7.0.4 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.