add_action('um_account_pre_update_profile', 'send_custom_email_on_profile_change', 10, 2);
function send_custom_email_on_profile_change($changes, $user_id) {
$data = get_userdata($user_id);
if (isset($changes['user_email']) && $data->user_email != $changes['user_email']) {
$new_email = $changes['user_email'];
$old_email = $data->user_email;
// Load the template file
$template_path = UM()->files()->plugin . 'ultimate-member/email/';
$email_content = file_get_contents($template_path . 'changedaccount_email.php');
// Replace placeholders with actual content
$email_content = str_replace('{{new_email}}', $new_email, $email_content);
$email_content = str_replace('{{old_email}}', $old_email, $email_content);
// Send the email
$to = array($new_email, $old_email);
$subject = 'Zmiana adresu e-mail w profilu';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($to, $subject, $email_content, $headers);
}
}
I tried smth like this but it doesnt work