0

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.

4
  • Scope isn't your problem. How are you testing this?
    – s_ha_dum
    Commented Nov 6, 2015 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
    Commented Nov 6, 2015 at 19:19
  • Would be interested in hearing a better way.
    – lime
    Commented Nov 6, 2015 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
    Commented Nov 6, 2015 at 19:25

1 Answer 1

0

$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' );
2
  • 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
    Commented Nov 6, 2015 at 19:55
  • You had it all along. It's get_bloginfo( 'url' ) Commented Nov 6, 2015 at 20:00

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.