send_confirmation_on_profile_email( int $user_id = 0 )
- Since
- 3.0.0, 4.9.0, 7.0.3
- Source
wp-includes/user.php:3867
Compatibility
- WordPress
- since 7.0.3
- 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
$user_idintoptional- The ID of the user whose email is being changed. Defaults to
$_POST['user_id']if set, otherwise 0.Default:0
Performance profile
How much work a call to send_confirmation_on_profile_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
- Scaling
- Constant
- Instructions
- 12–136
- Plugin surface
- 1 hook
- Called by
- 0
Sends mail via wp_mail().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 175.
Third-party callbacks on 'new_user_email_content' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()called directly - mailsends mail
wp_mail()called directly - querycontent query
get_user_by()one call below send_confirmation_on_profile_email() - transienttransient
get_transient()one call below send_confirmation_on_profile_email() - cacheobject cache
wp_cache_get()one call below send_confirmation_on_profile_email() - serializeserialisation
maybe_unserialize()one call below send_confirmation_on_profile_email()
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost send_confirmation_on_profile_email() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 12–27 | wp_get_current_user() |
isset($value) | 22–34 | absint(), wp_get_current_user() |
!is_email() | 43–49 | wp_get_current_user(), is_email(), __(), ->add(), addslashes() |
isset($value) && !is_email() | 53–56 | absint(), wp_get_current_user(), is_email(), __(), ->add(), addslashes() |
is_email() && email_exists() | 56–62 | wp_get_current_user(), is_email(), email_exists(), __(), ->add(), delete_user_meta(), addslashes() |
isset($value) && is_email() && email_exists() | 66–69 | absint(), wp_get_current_user(), is_email(), email_exists(), __(), ->add(), delete_user_meta(), addslashes() |
is_email() && !email_exists() | 123–129 | wp_get_current_user(), is_email(), email_exists(), time(), wp_rand(), md5(), update_user_meta(), get_option(), wp_specialchars_decode(), __(), apply_filters(), self_admin_url(), esc_url(), home_url(), __(), sprintf(), wp_mail() |
isset($value) && is_email() && !email_exists() | 133–136 | absint(), wp_get_current_user(), is_email(), email_exists(), time(), wp_rand(), md5(), update_user_meta(), get_option(), wp_specialchars_decode(), __(), apply_filters(), self_admin_url(), esc_url(), home_url(), __(), sprintf(), wp_mail() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 175 | 12–136 | 8 | |
| 8.5 | 175 | 12–136 | 8 | |
| 8.4 | 175 | 12–136 | 8 | 15 fewer instructions than PHP 8.3 |
| 8.3 | 190 | 12–151 | 8 | |
| 8.2 | 190 | 12–151 | 8 | |
| 8.1 | 190 | 12–151 | 8 | |
| 7.4 | 190 | 12–151 | 8 |
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 send_confirmation_on_profile_email() runs, in this order:
- apply_filters( new_user_email_content )filterline 3962 (+95 into the body)
Filters the text of the email sent when a change of user email address is attempted.
Uses · 16
- absint()Converts a value to non-negative integer.
- wp_get_current_user()Retrieves the current user object.
- is_email()Verifies that an email is valid.
- __()Retrieves the translation of $text.
- email_exists()Determines whether the given email exists.
- delete_user_meta()Removes metadata matching criteria from a user.
- wp_rand()Generates a random non-negative number.
- update_user_meta()Updates user meta field based on user ID.
- wp_specialchars_decode()Converts a number of HTML entities into their special characters.
- get_option()Retrieves an option value based on an option name.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_url()Checks and cleans a URL.
Show all 16
- self_admin_url()Retrieves the URL to the admin area for either the current site or the network depending on context.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- wp_mail()Sends an email, similar to PHP's mail function.
- WP_Error::__construct()Initializes the error.
Source code
function send_confirmation_on_profile_email( $user_id = 0 ) { global $errors; // Maintain backward compatibility for those relying on a check based on $_POST['user_id']. if ( ! $user_id && isset( $_POST['user_id'] ) ) { $user_id = absint( $_POST['user_id'] ); } $current_user = wp_get_current_user(); if ( ! is_object( $errors ) ) { $errors = new WP_Error(); } if ( 0 === $current_user->ID || $current_user->ID !== (int) $user_id ) { return false; } if ( $current_user->user_email !== $_POST['email'] ) { if ( ! is_email( $_POST['email'] ) ) { $errors->add( 'user_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email', ) ); $_POST['email'] = addslashes( $current_user->user_email ); return; } if ( email_exists( $_POST['email'] ) ) { $errors->add( 'user_email', __( '<strong>Error:</strong> The email address is already used.' ), array( 'form-field' => 'email', ) ); delete_user_meta( $current_user->ID, '_new_email' ); $_POST['email'] = addslashes( $current_user->user_email ); return; } $hash = md5( $_POST['email'] . time() . wp_rand() ); $new_user_email = array( 'hash' => $hash, 'newemail' => $_POST['email'], ); update_user_meta( $current_user->ID, '_new_email', $new_user_email ); $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ $email_text = __( 'Howdy ###USERNAME###, You recently requested to have the email address on your account changed. If this is correct, please click on the following link to change it:###ADMIN_URL### You can safely ignore and delete this email if you do not want totake this action. This email has been sent to ###EMAIL### Regards,All at ###SITENAME######SITEURL###' ); /** * Filters the text of the email sent when a change of user email address is attempted. * * The following strings have a special meaning and will get replaced dynamically: * * - `###USERNAME###` The current user's username. * - `###ADMIN_URL###` The link to click on to confirm the email change.Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$user_id parameter, which is sent with the personal_options_update action.from the docblockAbout 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.