Skip to:
Content
Pages
Categories
Search
Top
Bottom

change the email ‘from’ name (BuddyPress email templates)

  • @sm60

    Participant

    How do you change the email address and name (BuddyPress email templates).

    The following works only for WordPress emails such as the email to recover password, but it doesn’t work for any of the BuddyPress emails:

    
    // change email address
    function change_wp_mail_from( $email ){
    	return 'support@mysite.com';
    }
    add_filter( 'wp_mail_from', 'change_wp_mail_from' );
    
    // Change email name
    function change_wp_mail_name( $name ){
    	return 'My Site';
    }
    add_filter( 'wp_mail_from_name', 'change_wp_mail_name' );

    Any help appreciated.

Viewing 14 replies - 1 through 14 (of 14 total)
  • @shanebp

    Moderator

    Try:

    add_action( 'bp_email', function( $email_type, $email_obj ) {
        $email_obj->set_from( "custom@example.com", "Custom Website Name" );
    }, 10, 2 );

    https://codex.buddypress.org/emails/#filter-from-address-and-name

    @sharmavishal

    Participant

    @djpaul

    Keymaster

    FYI wp_mail_from_name and wp_mail_from support are coming back in BuddyPress 2.5.3. Thanks to everyone’s feedback regarding this.

    @dowen777

    Participant

    Is this problem causing BP emails to appear as text, for example:

    reaster@uillinois.edu

    Instead of as a mailto: link:

    reaster@uillinois.edu

    ?

    Same thing with BP images, see:

    http://thelincolnacademyofillinois.org/members/peter-bensinger/

    @dowen777

    Participant

    Sorry, this is how an email address is appearing on a profile page.

    <a href="mailto:Peter.bensinger@bensingerdupont.com">Peter.bensinger@bensingerdupont.com</a>

    @dowen777

    Participant

    When is BP 2.5.3 coming out?

    @dowen777

    Participant

    The problem is the < and > are being escaped, so the image is output as:

    <td class="data"><img src="http://thelincolnacademyofillinois.org/wp-content/uploads/profiles/16/peter-bensinger.jpg" alt="" /></td>

    instead of

    <td class="data"><img src="http://thelincolnacademyofillinois.org/wp-content/uploads/profiles/16/peter-bensinger.jpg" alt="" /></td>

    @dowen777

    Participant

    I can’t get the escaped characters to appear in a way that reflects what BuddyPress is outputting to the screen.

    @dowen777

    Participant

    Please look at the page:

    http://thelincolnacademyofillinois.org/members/peter-bensinger/

    You will see what I mean.

    @berkelmudez

    Participant
    add_action( 'bp_email', function( $email_type, &$email_obj ) {
    $email_obj->set_from( "noreply@mydomain.com", "Blog website" );
    }, 10, 2 );

    Using this returns 2 warnings for me.

    Warning: Parameter 2 to {closure}() expected to be a reference, value given in …/wp-includes/plugin.php on line 525

    Warning: Cannot modify header information – headers already sent by (output started at …/wp-includes/plugin.php:525) in …/wp-includes/pluggable.php on line 1171

    The mail still gets send but it won’t change the from email. I turned wp_mail on for now as I also don’t know how to change the bp mail, mail_from setting.

    add_filter( 'bp_email_use_wp_mail', '__return_true' );

    @sm60

    Participant

    @shanebp

    Thanks for the code. It seems to have one problem, but I think I fixed it, it now works for me.

    The code you provided:

    add_action( 'bp_email', function( $email_type, &$email_obj ) {
    	$email_obj->set_from( "custom@example.com", "Custom Website Name" );
    }, 10, 2 );

    This brings up this error right after signing up:
    Warning: Parameter 2 to {closure}() expected to be a reference, value given in /home/####/public_html/wp-includes/plugin.php on line 525

    Changing &$email_obj to $email_obj worked for me. The following code works:

    add_action( 'bp_email', function( $email_type, $email_obj ) {
    	$email_obj->set_from( "custom@example.com", "Custom Website Name" );
    }, 10, 2 );

    @shanebp

    Moderator

    Thx @sm60. I’ve adjusted my answer and the codex entry.

    @rodolvertice

    Participant

    Thanks for the code snippets.
    Question, is there a way to change the reply-to field in sent emails? I’ve tried to add it as extra arguments on the same set_from method, and i have also tried set_reply_to, but neither worked. The sent from works perfectly, but the reply-to keeps showing the wordpress main email.

    @wjh

    Participant

    @rodolvertice I found a solution by copying @shanebp’s code and replacing ‘set_from’ with ‘set_reply_to’, as in:

    add_action( 'bp_email', function( $email_type, $email_obj ) {
    	$email_obj->set_reply_to( "custom@example.com", "Custom Website Name" );
    }, 10, 2 );
Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.