Changing the default e-mail's from address

When you create your store, WooCommerce automatically uses the admin e-mail in WordPress as the default from address in e-mails. This is convenient for many users, but, you may want your site admin to only get admin e-mails and for someone else to get responses from customers. This can be done using one of the many WordPress hooks.

How to do it...

We'll need to add a little bit of code to modify the from address, by performing the following steps:

  1. Open up your theme's functions.php file or a custom WooCommerce plugin.
  2. At the bottom of the file, add the following code:
    add_filter( 'wp_mail_from', 'woocommerce_cookbook_wp_mail_from', 99 );

    This code tells WordPress that we want to change the standard from address in any e-mails sent. Now we need to actually write the function to do that.

  3. Add the following code beneath the preceding code:
    function woocommerce_cookbook_wp_mail_from() { 
        return html_entity_decode( '[email protected]' ); 
    }

    This function returns an e-mail address in the correct format to replace the default. You can, of course, change [email protected] to whatever you want.

  4. Save and upload the file.

Now, any e-mails you or your customers receive from your website should use that new address.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset