Change @WordPress from email address and from name sent out from website
Tento článek (nebo jeho část) je převzat z externího zdroje. Je tedy slušností jej uvést včetně případného autora.
WordPress sends a few emails out from a website including password reset emails that have a from email address wordpress@yoursite.com they also have a from name of WordPress.
Two WordPress filters can change these values wp_mail_from and wp_mail_from_name – add the below code in your child themes functions.php and change the appropriate values.
1 2 3 4 5 6 7 8 9 10 11 |
add_filter('wp_mail_from', 'prefix_email_from'); // Change default WordPress from email address function prefix_email_from( $new_email ) { return 'admin@newadress.com'; // Change email address } add_filter('wp_mail_from_name', 'prefix_name_from'); // Change default WordPress from name function prefix_name_from( $new_name ) { return 'Company Name'; // Change from name } |
You could also bring in option values already created in the Settings > General page and use the Blogname and Admin Email values…
1 2 3 4 5 6 7 8 9 10 11 12 13 |
add_filter('wp_mail_from', 'prefix_email_from'); // Change default WordPress from email address function prefix_email_from( $new_email ) { $admin_email = get_option( 'admin_email' ); return $admin_email; } add_filter('wp_mail_from_name', 'prefix_name_from'); // Change default WordPress from name function prefix_name_from( $new_name ) { $blogname = get_option( 'blogname' ); return $blogname; } |
Napsat komentář