Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP 2.4.x to 2.5 wp_mail_from not working with new emails in BP


  • mi423
    Participant

    @mi423

    Hello.
    After last update of BP (2.5.0) my function hooked in to filters: ‘wp_mail_from’, ‘wp_mail_from_name’ is not working any more, email sends from “wordpress@example.com” instead of “custom@example.com”

    Before BP update every things was ok.

Viewing 3 replies - 1 through 3 (of 3 total)

  • mi423
    Participant

    @mi423

    forgot to mention: WordPress 4.4.2

    Hi @mi423.

    Yes, this is intentional.

    BuddyPress 2.5 uses its own implementation of emails under-the-hood. We no longer use wp_mail. A consequence means that anything hooked to actions or filters specific to wp_mail no longer work. wp_mail_from and wp_mail_from_name is an example of this.
    I apologise for the inconvenience.

    There are a few ways to achieve this; you can either change the value after the default is *set*, or change it when the value is *read*. For simplicity, I’d suggest the first. This should work though I haven’t tested it:

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

    EDIT: sample code tested and updated on March 4.


    mi423
    Participant

    @mi423

    hmm ok, didn’t know that.
    Thx for clarification and example.

    cheers
    resolved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘BP 2.4.x to 2.5 wp_mail_from not working with new emails in BP’ is closed to new replies.
Skip to toolbar