Skip to content

Customizing the New Admin Email Confirmation in WordPress

When you change the email address of a WordPress site’s administrator in the wp-admin Settings > General tab, an email is sent to the new email address. This email contains a link that must be visited for the change to take effect.

The default email arrives with the subject line [Site Name] New Admin Email Address and the body:

Howdy adminuser,

Someone with administrator capabilities recently requested to have the
administration email address changed on this site:
https://example.com/

To confirm this change, please click on the following link:
https://example.com/wp-admin/options.php?adminhash=b5c09114c1c7f3b55e53f4b805fb5b9f

You can safely ignore and delete this email if you do not want to
take this action.

This email has been sent to [email protected]

Regards,
All at Test Site
https://example.com/

There are two filters available for you to modify the contents of this email, one for the body, and one for the subject line.

Changing the Body

This filter is available in WordPress 4.9 and above.

To change the body of the email, use the new_admin_email_content filter. This filter includes 5 placeholder variables that you can insert into the body contents:

  • ###ADMIN_URL### is the link you need to visit in order for the change in email address to take effect.
  • ###USERNAME### to display the username of the administrator who was logged in when the admin email address was changed in the dashboard.
  • ###SITEURL### to display the URL of the site affected by this change.
  • ###SITENAME## to display the name of the site being affected by the change.
  • ###EMAIL### to display the email address of the proposed new administrator. This is the same email that this confirmation email is sent to.

Example:

Add this code to your theme’s functions.php file or to custom plugin code:

add_filter('new_admin_email_content', 'my_admin_email_content', 10, 2);

function my_admin_email_content($email_text, $new_admin_email) {

   return "Hi ###USERNAME!

To confirm the change in administrator on '###SITENAME###' email to ###EMAIL###, click on the link below:

###ADMIN_URL###

If you don't want to make this change, ignore this email. 
";

}

Changing the Subject Line

This filter is available in WordPress 6.5 and above.

To change the email’s subject line, use the new_admin_email_subject filter. This filter doesn’t have any placeholders, it’s just a simple string.

Example:

Add this code to your theme’s functions.php file or to custom plugin code:

add_filter('new_admin_email_subject', 'my_admin_email_subject', 10, 1);

function my_admin_email_subject($subject) {
   $site_url = home_url();

   return "[Action Required] Admin Email Address Change for $site_url";

}

One Comment

  1. Hey Shawn. Thanks for the blog post. The Admin Email Address is one that I’m particularly interested in right now as I have a WordPress Trac ticket in the queue regarding how to deal with getting removed from that field. A lot of WordPress devs make themselves the admin email address, but later when someone else takes over, they get stuck receiving all of the admin messages, often for years, with no way to change it. Here’s the link for anyone who wants to see it and give it a star. https://core.trac.wordpress.org/ticket/60789

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.