Change sub-sites default email

I'm trying to set the default email from subsites on our WPressr multisite. I put this in the mu-plugins but it doesn't seem to work: http://collabedit.com/dbxsq

<?php
/* Plugin to set the default email from information per site for WPressr
* Subdomain = "Sitename" <mail@wpressr.com>
* Mapdomain = "Sitename" <mail@domain.com>
*/

add_filter( 'wp_mail_from', 'new_mail_from' );
add_filter( 'wp_mail_from_name', 'new_mail_from_name' );
function new_mail_from( $old ) {
$parse = parse_url(get_bloginfo('url'));
return 'mail@'.$parse['host'];
}
function new_mail_from_name( $old ) {
return get_bloginfo('name');
}

  • Ash

    Hello us-Sunnah

    I have tested your code and it worked fine on my site. I have sent email with subsite and printed in the footer, both time it got mapped domain in the email address domain.

    So, I think in your site, there might be two cases.
    1. The email is sent from network level, not subsite level, that's why it's getting main site domain.
    2. There could be same filter used in your site with higher priority, so your code gets overwritten. To avoid this one, you can try increasing the priority like below:

    add_filter( 'wp_mail_from', 'new_mail_from', 9999 );
    add_filter( 'wp_mail_from_name', 'new_mail_from_name', 9999 );
    function new_mail_from( $old ) {
    $parse = parse_url(get_bloginfo('url'));
    return 'mail@'.$parse['host'];
    }
    function new_mail_from_name( $old ) {
    return get_bloginfo('name');
    }

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash