update_option_new_admin_email

Sends an email when a site administrator email address is changed.

Description

update_option_new_admin_email( (string) $old_value, (string) $value ); 

Parameters (2)

0. $old_value (string)
The old email address. Not currently used.
1. $value (string)
The new email address.

Usage

  1. if ( !function_exists( 'update_option_new_admin_email' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ms.php'; 
  3.  
  4. // The old email address. Not currently used. 
  5. $old_value = ''; 
  6.  
  7. // The new email address. 
  8. $value = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = update_option_new_admin_email($old_value, $value); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ms.php  
  1. function update_option_new_admin_email( $old_value, $value ) { 
  2. if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) 
  3. return; 
  4.  
  5. $hash = md5( $value. time() .mt_rand() ); 
  6. $new_admin_email = array( 
  7. 'hash' => $hash,  
  8. 'newemail' => $value 
  9. ); 
  10. update_option( 'adminhash', $new_admin_email ); 
  11.  
  12. $switched_locale = switch_to_locale( get_user_locale() ); 
  13.  
  14. /** translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ 
  15. $email_text = __( 'Howdy ###USERNAME###,  
  16.  
  17. You recently requested to have the administration email address on 
  18. your site changed. 
  19.  
  20. If this is correct, please click on the following link to change it: 
  21. ###ADMIN_URL### 
  22.  
  23. You can safely ignore and delete this email if you do not want to 
  24. take this action. 
  25.  
  26. This email has been sent to ###EMAIL### 
  27.  
  28. Regards,  
  29. All at ###SITENAME### 
  30. ###SITEURL###' ); 
  31.  
  32. /** 
  33. * Filters the email text sent when the site admin email is changed. 
  34. * The following strings have a special meaning and will get replaced dynamically: 
  35. * ###USERNAME### The current user's username. 
  36. * ###ADMIN_URL### The link to click on to confirm the email change. 
  37. * ###EMAIL### The new email. 
  38. * ###SITENAME### The name of the site. 
  39. * ###SITEURL### The URL to the site. 
  40. * @since MU 
  41. * @param string $email_text Text in the email. 
  42. * @param string $new_admin_email New admin email that the current administration email was changed to. 
  43. */ 
  44. $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email ); 
  45.  
  46. $current_user = wp_get_current_user(); 
  47. $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); 
  48. $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content ); 
  49. $content = str_replace( '###EMAIL###', $value, $content ); 
  50. $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content ); 
  51. $content = str_replace( '###SITEURL###', network_home_url(), $content ); 
  52.  
  53. wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content ); 
  54.  
  55. if ( $switched_locale ) {