1

I used this code for changing the email sender name from Wordpress to my own title.

function wpb_sender_email($original_email_address)
{
    return '[email protected]';
}

// Function to change sender name
function wpb_sender_name($original_email_from)
{
    return 'mydomain.com';
}

// Hooking up our functions to WordPress filters
add_filter('wp_mail_from', 'wpb_sender_email');
add_filter('wp_mail_from_name', 'wpb_sender_name');

But it just changes welcome emails. when a user wants to change his/her email, the email notification send by [email protected] So how can I change it too?

3 Answers 3

2

As of version 4.9 there is a dubious "feature" that prevents you from changing the site email without a confirmation email going out, and the admin confirming his own change. Those filters, as you've discovered, won't work.

For instance, from now on, if you're using WordPress for an IOT device or on localhost, it's impossible for an admin to change the site admin address on a single site.

You'll have to remove the new hooks, and plop in your own. I put a plugin on the .org repo that does this. You can use that and just put your own values in. https://wordpress.org/plugins/change-admin-email-setting-without-outbound-email/

Here is the code on Github: https://github.com/JohnDeeBDD/change-admin-email/blob/master/change-admin-email.php

1
  • thanks. and is there any code for putting on function. without installing the plugin?
    – joei
    Commented Aug 2, 2018 at 12:31
1

Paste this below code your current active functions.php file

function custom_wp_mail_from_name($from_name){
return “Custom Name”;
}

add_filter(“wp_mail_from_name”, “custom_wp_mail_from_name”);


function custom_wp_mail_from($email){
return “[email protected]”;
}
add_filter(“wp_mail_from”, “custom_wp_mail_from”);
1
  • thanks but it does not work. and email and sender name do not change.
    – joei
    Commented Aug 2, 2018 at 12:30
0

Try this in your functions.php file: (Although it adds spaces between CamelCase words -- does anybody know how to remedy that?)

function wpb_sender_email( $original_email_address ) {
return '[email protected]';
}
function wpb_sender_name( $original_email_from ) {
return 'MySiteAdmin';
}
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.