Inside a plugin, I am attempting to filter the WordPress 'from' email name to a dynamic value instead of the default 'WordPress'.

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

This is not returning anything. I feel like it has something to do with scope.

  • Scope isn't your problem. How are you testing this? – s_ha_dum Nov 6 '15 at 19:19
  • I am uploading the plugin to the server, resetting the users password to have the server actually send an email out. – lime Nov 6 '15 at 19:19
  • Would be interested in hearing a better way. – lime Nov 6 '15 at 19:20
  • 2
    You need to eliminate the assumption that get_bloginfo is returning a valid value, and not an invalid value, or an empty value – Tom J Nowell Nov 6 '15 at 19:25

$get_bloginfo() function is root scoped.

For a measure of confidence, it's good to know it is used by the wp_mail function in the pluggable.php file.

// If we don't have a charset from the input headers
if ( !isset( $charset ) )
    $charset = get_bloginfo( 'charset' );
| improve this answer | |
  • I am still not following. Would anyone be willing to type out a function that would return the site url. I'd like to break it down to understand better. – lime Nov 6 '15 at 19:55
  • You had it all along. It's get_bloginfo( 'url' ) – Scriptonomy Nov 6 '15 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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