Title: update_option_new_admin_email
Published: April 25, 2014
Last modified: May 20, 2026

---

# update_option_new_admin_email( string $old_value, string $value )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#wp--skip-link--target)

Sends a confirmation request email when a change of site admin email address is 
attempted.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#parameters)󠁿

 `$old_value`stringrequired

The old site admin email address.

`$value`stringrequired

The proposed new site admin email address.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#source)󠁿

    ```php
    function update_option_new_admin_email( $old_value, $value ) {
    	if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
    		return;
    	}

    	$hash            = md5( $value . time() . wp_rand() );
    	$new_admin_email = array(
    		'hash'     => $hash,
    		'newemail' => $value,
    	);
    	update_option( 'adminhash', $new_admin_email, false );

    	$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,

    A site administrator (###USERNAME###) recently requested to have the
    administration email address changed on this site:
    ###SITEURL###

    To confirm this change, please click on the following link:
    ###ADMIN_URL###

    You can safely ignore and delete this email if you do not want to
    take 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 site 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 site admin email address.
    	 *  - `###SITENAME###`  The name of the site.
    	 *  - `###SITEURL###`   The URL to the site.
    	 *
    	 * @since MU (3.0.0)
    	 * @since 4.9.0 This filter is no longer Multisite specific.
    	 *
    	 * @param string $email_text      Text in the email.
    	 * @param array  $new_admin_email {
    	 *     Data relating to the new site admin email address.
    	 *
    	 *     @type string $hash     The secure hash used in the confirmation link URL.
    	 *     @type string $newemail The proposed new site admin email address.
    	 * }
    	 */
    	$content = apply_filters( 'new_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( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
    	$content      = str_replace( '###EMAIL###', $value, $content );
    	$content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
    	$content      = str_replace( '###SITEURL###', home_url(), $content );

    	if ( '' !== get_option( 'blogname' ) ) {
    		$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    	} else {
    		$site_title = parse_url( home_url(), PHP_URL_HOST );
    	}

    	$subject = sprintf(
    		/* translators: New admin email address notification email subject. %s: Site title. */
    		__( '[%s] New Admin Email Address' ),
    		$site_title
    	);

    	/**
    	 * Filters the subject of the email sent when a change of site admin email address is attempted.
    	 *
    	 * @since 6.5.0
    	 *
    	 * @param string $subject Subject of the email.
    	 */
    	$subject = apply_filters( 'new_admin_email_subject', $subject );

    	wp_mail( $value, $subject, $content );

    	if ( $switched_locale ) {
    		restore_previous_locale();
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/misc.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/misc.php#L1450)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/misc.php#L1450-L1542)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#hooks)󠁿

 [apply_filters( ‘new_admin_email_content’, string $email_text, array $new_admin_email )](https://developer.wordpress.org/reference/hooks/new_admin_email_content/)

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

 [apply_filters( ‘new_admin_email_subject’, string $subject )](https://developer.wordpress.org/reference/hooks/new_admin_email_subject/)

Filters the subject of the email sent when a change of site admin email address 
is attempted.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#related)󠁿

| Uses | Description | 
| [switch_to_user_locale()](https://developer.wordpress.org/reference/functions/switch_to_user_locale/)`wp-includes/l10n.php` |

Switches the translations according to the given user’s locale.

  | 
| [restore_previous_locale()](https://developer.wordpress.org/reference/functions/restore_previous_locale/)`wp-includes/l10n.php` |

Restores the translations according to the previous locale.

  | 
| [is_email()](https://developer.wordpress.org/reference/functions/is_email/)`wp-includes/formatting.php` |

Verifies that an email is valid.

  | 
| [wp_specialchars_decode()](https://developer.wordpress.org/reference/functions/wp_specialchars_decode/)`wp-includes/formatting.php` |

Converts a number of HTML entities into their special characters.

  | 
| [wp_rand()](https://developer.wordpress.org/reference/functions/wp_rand/)`wp-includes/pluggable.php` |

Generates a random non-negative number.

  | 
| [wp_get_current_user()](https://developer.wordpress.org/reference/functions/wp_get_current_user/)`wp-includes/pluggable.php` |

Retrieves the current user object.

  | 
| [wp_mail()](https://developer.wordpress.org/reference/functions/wp_mail/)`wp-includes/pluggable.php` |

Sends an email, similar to PHP’s mail function.

  | 
| [self_admin_url()](https://developer.wordpress.org/reference/functions/self_admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for either the current site or the network depending on context.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [get_current_user_id()](https://developer.wordpress.org/reference/functions/get_current_user_id/)`wp-includes/user.php` |

Gets the current user’s ID.

  |

[Show 10 more](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | This function was moved from wp-admin/includes/ms.php so it’s no longer Multisite specific. | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/?output_format=md#comment-content-1523)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/update_option_new_admin_email/#comment-1523)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fupdate_option_new_admin_email%2F%23comment-1523)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fupdate_option_new_admin_email%2F%23comment-1523)
 4. **Disable the confirmation notices when an administrator changes their email address.**
 5.     ```php
        remove_action( 'add_option_new_admin_email', 'update_option_new_admin_email' );
        remove_action( 'update_option_new_admin_email', 'update_option_new_admin_email' );
    
        /**
         * Disable the confirmation notices when an administrator
         * changes their email address.
         *
         * @see http://codex.wordpress.com/Function_Reference/update_option_new_admin_email
         */
        function wpdocs_update_option_new_admin_email( $old_value, $value ) {
    
        	update_option( 'admin_email', $value );
        }
        add_action( 'add_option_new_admin_email', 'wpdocs_update_option_new_admin_email', 10, 2 );
        add_action( 'update_option_new_admin_email', 'wpdocs_update_option_new_admin_email', 10, 2 );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fupdate_option_new_admin_email%2F%3Freplytocom%3D1523%23feedback-editor-1523)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fupdate_option_new_admin_email%2F)
before being able to contribute a note or feedback.