Support » Plugin: BuddyPress Registration Options » Change Sender Email From WordPress

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks like those can be custom set by using the 4th argument for wp_mail() function calls, but we never get to that point, so our plugin at least defaults to all of WordPress’ default values.

    That said, WordPress core does have some filters that can be used to set the “From name” and “From email”.

    	/**
    	 * Filters the email address to send from.
    	 *
    	 * @since 2.2.0
    	 *
    	 * @param string $from_email Email address to send from.
    	 */
    	$from_email = apply_filters( 'wp_mail_from', $from_email );
    
    	/**
    	 * Filters the name to associate with the "from" email address.
    	 *
    	 * @since 2.3.0
    	 *
    	 * @param string $from_name Name associated with the "from" email address.
    	 */
    	$from_name = apply_filters( 'wp_mail_from_name', $from_name );
    

    The thing with these is that they would be global to all uses of wp_mail() at this point, and not just our emails.

    If you need some help working with the filters, I can provide some example usage for them.

    Hi, thanks for the prompt response…

    Pls how do i add these filters to change the “From name” and “From email”.

    I’ll appreciate your step by step guidance.

    Thanks

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Basic example, but these would go in your active theme’s functions.php

    function beetcore_change_from_email( $original ) {
    	return 'foo@bar.com';
    }
    add_filter( 'wp_mail_from', 'beetcore_change_from_email' );
    
    function beetcore_change_from_name( $original ) {
    	return 'Foo Bar';
    }
    add_filter( 'wp_mail_from_name', 'beetcore_change_from_name' );
    

    Hi, thanks for this…
    Can i substitute what you have there with mine, e.g.

    —————

    function beetcore_change_from_email( $original ) {
    return ‘support@beetcore.com’;
    }
    add_filter( ‘wp_mail_from’, ‘beetcore_change_from_email’ );

    function beetcore_change_from_name( $original ) {
    return ‘Support Beetcore’;
    }
    add_filter( ‘wp_mail_from_name’, ‘beetcore_change_from_name’ );

    ——————

    Will above work?

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Looks fine to me, and of course you can change those spots, I just put in dummy text to demo it all.

    It created an error http://prntscr.com/jtob72
    I guess cos i use PageLines Framework…

    So i googled it and came across this plugin CB Mail Sender, which solved the challenge.

    Thanks a lot 🙂

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Odd that that’s causing an internal server error. The only source I can think of for it would be “bad” quotes due to copy/paste from the forum here.

    Regardless, you have something working now, which is the important part.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change Sender Email From WordPress’ is closed to new replies.