wppaste
WordPress

update_network_option_new_admin_email( string $old_value, string $value )

Since
4.9.0
Source
wp-includes/ms-functions.php:2724
Sends a confirmation request email when a change of network admin email address is attempted.

Description

The new network admin address will not become active until confirmed.

Compatibility

WordPress
since 4.9.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

$old_valuestring
The old network admin email address.
$valuestring
The proposed new network admin email address.

Performance profile

How much work a call to update_network_option_new_admin_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
8–102

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

Plugin surface
1 hook

Third-party callbacks on 'new_network_admin_email_content' 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

  • optionnetwork optionget_site_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • mailsends mailwp_mail()called directly

Further down the call graph this can also reach cache, serialize, query 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 · 4 distinct outcomes

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

WhenInstructionsCalls it makes
$value === false8get_site_option()
$value !== false && !is_email()12get_site_option(), is_email()
$value !== false && is_email()100get_site_option(), is_email(), time(), mt_rand(), md5(), update_site_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), network_admin_url(), esc_url(), get_site_option(), wp_specialchars_decode(), network_home_url(), __(), get_site_option(), wp_specialchars_decode(), sprintf(), wp_mail()
$value !== false && is_email()102get_site_option(), is_email(), time(), mt_rand(), md5(), update_site_option(), get_current_user_id(), switch_to_user_locale(), __(), apply_filters(), wp_get_current_user(), network_admin_url(), esc_url(), get_site_option(), wp_specialchars_decode(), network_home_url(), __(), get_site_option(), wp_specialchars_decode(), sprintf(), wp_mail(), restore_previous_locale()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1038–1023
8.51038–1023
8.41038–102315 fewer instructions than PHP 8.3
8.31188–1173
8.21188–1173
8.11188–1173
7.41188–1173

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 update_network_option_new_admin_email() runs, in this order:

  1. apply_filters( new_network_admin_email_content )filterline 2778 (+54 into the body)

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

Uses · 14

Show all 14

Source code

function update_network_option_new_admin_email( $old_value, $value ) {	if ( get_site_option( 'admin_email' ) === $value || ! is_email( $value ) ) {		return;	} 	$hash            = md5( $value . time() . mt_rand() );	$new_admin_email = array(		'hash'     => $hash,		'newemail' => $value,	);	update_site_option( 'network_admin_hash', $new_admin_email ); 	$switched_locale = switch_to_user_locale( get_current_user_id() ); 	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */	$email_text = __(		'Howdy ###USERNAME###, You recently requested to have the network admin email address onyour network 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 network admin 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 proposed new network admin email address.	 * ###SITENAME###  The name of the network.	 * ###SITEURL###   The URL to the network.	 *	 * @since 4.9.0	 *	 * @param string $email_text      Text in the email.	 * @param array  $new_admin_email {	 *     Data relating to the new network admin email address.	 *	 *     @type string $hash     The secure hash used in the confirmation link URL.	 *     @type string $newemail The proposed new network admin email address.	 * }	 */	$content = apply_filters( 'new_network_admin_email_content', $email_text, $new_admin_email ); 	$current_user = wp_get_current_user();	$content      = str_replace( '###USERNAME###', $current_user->user_login, $content );	$content      = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );	$content      = str_replace( '###EMAIL###', $value, $content );	$content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );	$content      = str_replace( '###SITEURL###', network_home_url(), $content ); 	wp_mail(		$value,		sprintf(			/* translators: Email change notification email subject. %s: Network title. */			__( '[%s] Network Admin Email Change Request' ),			wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES )		),		$content	); 	if ( $switched_locale ) {		restore_previous_locale();	}}

Changelog

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

About this page

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