I want to modularly disable emails sent out by WordPress so I can replace them with my own custom emails when necessary.
This is my custom Welcome Email:
function send_welcome_email_to_new_user($user_id) {
$user = get_userdata($user_id);
$user_email = $user->user_email;
// for simplicity, lets assume that user has typed their first and last name when they sign up
$user_full_name = $user->user_firstname . $user->user_lastname;
// Now we are ready to build our welcome email
$to = $user_email;
$subject = "Hi " . $user_full_name . ", welcome to our site!";
$body = '
<h1>Dear ' . $user_full_name . ',</h1></br>
<p>Thank you for joining our site. Your account is now active.</p>
<p>Please go ahead and navigate around your account.</p>
<p>Let me know if you have further questions, I am here to help.</p>
<p>Enjoy the rest of your day!</p>
<p>Kind Regards,</p>
<p>poanchen</p>
';
$headers = array('Content-Type: text/html; charset=UTF-8');
if (wp_mail($to, $subject, $body, $headers)) {
error_log("email has been successfully sent to user whose email is " . $user_email);
}else{
error_log("email failed to sent to user whose email is " . $user_email);
}
}
When I create a new user, I got 2 email notification: my own custom email and wordpress default email. I want to hide the wordpress default email from the inbox.
How can I disable WordPress emails notifications to achieve this?
- Thank you for signing up/New User registration email