Hi,
I need to customize the email addresses RentalHive uses to send notifications based on specific events. Currently, all communications are sent from a single email, but I want certain events, such as password reset, email verification, and user registration, to use a separate email address (support@…) to better manage communications and provide a better experience for users.
Not knowing if there is an easier option, I made this code for functions.php. But I don’t know if it works correctly.
function custom_email_from_for_specific_events( $email_data ) {
$custom_slugs = array('user_password_request', 'user_email_verify', 'user_register');
if ( isset($email_data['slug']) && in_array($email_data['slug'], $custom_slugs) ) {
$email_data['from'] = 'support@yourdomain.com';
$email_data['from_name'] = 'Support';
}
return $email_data;
}
add_filter( 'wp_mail', 'custom_email_from_for_specific_events' );
Thanks.