Last active
July 19, 2021 17:29
-
-
Save butlerblog/08aa73c754ee5c1cc86cd29444d38a4c to your computer and use it in GitHub Desktop.
Change the #wp_mail "to" address based on subject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a filter for wp_mail(). It checks the subject | |
* for the presence of a given string (in this case "New | |
* User Registration"), and if that returns true it | |
* sets the "to" address/value. | |
*/ | |
add_filter( 'wp_mail', 'my_wp_mail_filter' ); | |
function my_wp_mail_filter( $args ) { | |
// Check the message subject for a known string in the notification email. | |
if ( strpos( $args['subject'], 'New User Registration' ) ) { | |
// This is the notification email, so change the "to" address. | |
$args['to'] = '[email protected]'; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment