Changing the Default Wordpress Email From Name — Indivision Interactive Agency
post-template-default,single,single-post,postid-293,single-format-standard,bridge-core-3.0.2,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-overridden-elementors-fonts,qode-child-theme-ver-1.0.0,qode-theme-ver-28.8,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.9.0,vc_responsive,elementor-default,elementor-kit-856

Changing the Default WordPress Email From Name


The Problem

By default, emails sent out from WordPress installations appear as being from “WordPress.” This is less than ideal from a branding perspective. Worse, it may prevent some recipients from reading the email if they don’t recognize who sent it.

There are a few solutions for this floating around. Apparently, there is (or was) a plug-in available that addresses this. I couldn’t find it. But, I didn’t look very long because adding another plug-in for this small adjustment seems like over-kill to me. Another solution is to directly change WordPress code so that instead of being hard-coded to use “WordPress”, it would then be hard-coded to use “Your Admin Name”. The problem with that is that you would then have to re-apply the change every time WordPress updates.

The Solution: Use a Filter

The solution I settled on is to implement a simple filter. It works by assigning a function to return the value to use for a variable, anywhere that variable is used. In the case below, the function is designed to return the name of the WordPress installation whenever¬†wp_mail_from_name is used. The advantage of this approach is that upgrading WordPress won’t break it. If you’re using a child theme, theme upgrades won’t break it either.

To implement this solution, add the following code to your themes functions.php file:

function get_blogname($name = '') {
     return get_bloginfo('name');
add_filter('wp_mail_from_name', 'get_blogname');

An alternative configuration would be to have the function send out some other email from name that you want to use. For example:

function get_fromname($name = '') {
     return " Admin";
add_filter('wp_mail_from_name', 'get_fromname');

Let us know if you find this helpful or have any questions!

UPDATE: Here is a link to the WordPress codex reference on this subject. The email from-name can be addressed in the code where wp_mail is used (though, that isn’t always practical if you are relying on theme or plug-in updates). Also, it should be noted that the above method could over-ride from-names for multiple kinds of emails being sent out some of which you may not want to change. Thanks to Thomas Scholz and Andrew Smith for these additional notes.

No Comments

Post A Comment