Change From and Email Address names in WordPress

You may want to Reset Your Password when you get locked out of your own WordPress Account or for Security Purpose. However, there are various ways to Change/Reset your Password. You can modify it from WordPress Dashboard or via PHPMyAdmin Database if you are a site Admin and have full access to the site’s CPanel. The other global step for password reset is simply hitting Lost your password? button from the WordPress Login Page. You then enter your email address or username in the input field and you’ll get

You then enter your email address or username in the input field and you’ll get password reset link in your mail that you have provided for password reset. But have you noticed the unusual or unwonted issue in your email? The incoming mailing address and the name are by default from WordPress and [email protected] You can, however, change From and Email Address names in WordPress. Just insert the following code in your Child Theme’s functions.php file.

Change From and Email Address names in WordPress

 

Change From and Email Address names in WordPress


Before code, Your incoming email looks like this:

Change From and Email Address names in WordPress

The following two hooks will deliver your need. Just add these in your active theme’s functions.php

// Change Password Reset Email Address
add_filter( 'wp_mail_from', 'pp_new_mail_from' );
function pp_new_mail_from( $old ) {
return '[email protected]'; // Edit it with your email address
}
// Change Password Reset Name
add_filter('wp_mail_from_name', 'pp_new_mail_from_name');
function pp_new_mail_from_name( $old ) {
return 'Company Name'; // Edit it with your/company name
}

After Code, Your incoming email looks like this:

Change From and Email Address names in WordPress

There is also another hook you might be interested which also works like above. Using below code will directly send mail given in WordPress Settings > General page. The email and name are grasped from WordPress Setting itself. Use the following code in your functions.php file

add_filter( 'wp_mail_from', 'pp_new_mail_from' );
function pp_new_mail_from( $old ) {
return get_option( 'admin_email' );
}

add_filter( 'wp_mail_from_name', 'pp_new_mail_from_name' );
function pp_new_mail_from_name( $old ) {
return get_option( 'blogname' );
}

Now, we’re finally done here. Comment below if you have any suggestion or query.