Skip to:
Content
Pages
Categories
Search
Top
Bottom

wp_mail_from BP_email


  • blogook
    Participant

    @jgob

    Hi,

    the filter wp_mail_from doesn’t work anymore. In this forum i read that the code below should be used. But it doesnt work. I use twentywtelve Buddypress 2.5.0 and latest WP

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

    Thanks in advance,
    B

Viewing 7 replies - 1 through 7 (of 7 total)
  • It ought to work. I wrote that code but it came with the disclaimer that I hadn’t actually tested it. 🙂

    If someone wants to test it and correct if it necessary, that’d be helpful, else I will try to look this weekend.


    Henry Wright
    Moderator

    @henrywright

    Check you’re running PHP 5.3 or higher, just in case that’s the issue.


    blogook
    Participant

    @jgob

    I am running :

    PHP 5.5.9-1ubuntu4.14 (cli)

    The function is not called at all. I tried to change add_action into add_filter, also that didn’t do anything.


    blogook
    Participant

    @jgob

    I also try to play a bit with available filters, the one below is also not working.

    add_filter( 'bp_email_set_from', 'mijnmeel1',10,4);
    
    function mijnmeel1( $from, $email_address, $name, $this ) {
        dd($from);  // dd = kint debugger
    }

    p.s.
    I am using these functions in my own plugin.

    I just updated the sample code on the thread you mentioned. I tested it and had to make a small change:

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

    This ^ works for me. I put it into a file in mu-plugins for convenience.

    Note: the from address must be valid. If you put a fake address in there, your mail provider will probably reject the email and not sent it.

    For example, if you use Google Mail via IMAP to send your site’s emails, Google will *force* the From address to be the account’s email address. You can see this by inspecting the raw email headers: http://cl.ly/42001Q2c142S


    blogook
    Participant

    @jgob

    confirmed. it works.

    On a side note. When I change the password of a user on the admin side of WP, it doesn’t make use of bp_email? How can I make use of bp_email and the nice format when changing emails?

    Anyway, thanks a bunch ! 🙂

    Cool!


    @jgob
    https://github.com/WordPress/WordPress/blob/ef7a559e2e7804844f99034e4ec018c5ffbf66c9/wp-includes/pluggable.php#L1700

    There’s no way to filter or halt the action; I suppose it MIGHT be possible to intercept it inside wp_mail() but it’d be awkward.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘wp_mail_from BP_email’ is closed to new replies.
Skip to toolbar