You can use the filters:
and update the admin email address using str_replace()
.
Each of the above filters accepts 3 parameters (arrays):
$email_change_email
or $pass_change_email
(depending on filter used)
$user
$userdata
The first parameter has an array item called message
which holds some strings which are dynamically replaced:
###USERNAME###
The current user's username.
###ADMIN_EMAIL###
The admin email in case this was unexpected.
###EMAIL###
The user's email address.
###SITENAME###
The name of the site.
###SITEURL###
The URL to the site.
Complete code:
Change other_email@your-domain.com
to your new admin email address.
/**
* Change admin email in notifications.
*
* This applies to password and email change notifications.
*
* @param (array) $pass_change_email Used to build wp_mail().
* @param (array) The original user array.
* @param (array) The updated user array.
*
* @return (array) $pass_change_email Updated wp_mail() content.
*/
add_filter('password_change_email', 'replace_admin_email_in_notification_emails', 10, 3);
add_filter('email_change_email', 'replace_admin_email_in_notification_emails', 10, 3);
function replace_admin_email_in_notification_emails( $pass_change_email, $user, $userdata ) {
$pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', 'other_email@your-domain.com', $pass_change_email['message'] );
return $pass_change_email;
}