wppaste
WordPress

send_confirmation_on_profile_email( int $user_id = 0 )

Since
3.0.0, 4.9.0, 7.0.3
Source
wp-includes/user.php:3710
Sends a confirmation request email when a change of user email address is attempted.

Parameters

$user_idintoptional
The ID of the user whose email is being changed. Defaults to $_POST['user_id'] if set, otherwise 0.Default: 0

Hooks fired · 1

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

  1. apply_filters( new_user_email_content )filterline 3804 (+94 into the body)

    Filters the text of the email sent when a change of user email address is attempted.

Uses · 16

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

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.		 * - ###EMAIL###     The new email.

History

Introduced in 3.0.0. 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.

7.0.3
Added the $user_id parameter, which is sent with the personal_options_update action.from the docblock
4.9.0
This function was moved from wp-admin/includes/ms.php so it's no longer Multisite specific.from the docblock
3.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 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.