diff --git a/enrol/self/lib.php b/enrol/self/lib.php index 2e425a6791a..32c9d48e643 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -291,7 +291,7 @@ class enrol_self_plugin extends enrol_plugin { if ($rusers) { $contact = reset($rusers); } else { - $contact = get_admin(); + $contact = generate_email_supportuser(); } //directly emailing welcome message rather than using messaging diff --git a/lib/cronlib.php b/lib/cronlib.php index b0347606e13..bcadaeb45b5 100644 --- a/lib/cronlib.php +++ b/lib/cronlib.php @@ -709,7 +709,7 @@ function notify_login_failures() { mtrace('Emailing admins about '. $count .' failed login attempts'); foreach ($recip as $admin) { //emailing the admins directly rather than putting these through the messaging system - email_to_user($admin,get_admin(), $subject, $body); + email_to_user($admin, generate_email_supportuser(), $subject, $body); } } diff --git a/user/edit.php b/user/edit.php index ca52ed30746..b3cedb28475 100644 --- a/user/edit.php +++ b/user/edit.php @@ -181,7 +181,8 @@ if ($usernew = $userform->get_data()) { $email_changed_html = ''; if ($CFG->emailchangeconfirmation) { - // Handle change of email carefully for non-trusted users + // Users with 'moodle/user:update' can change their email address immediately + // Other users require a confirmation email if (isset($usernew->email) and $user->email != $usernew->email && !has_capability('moodle/user:update', $systemcontext)) { $a = new stdClass(); $a->newemail = $usernew->preference_newemail = $usernew->email; @@ -235,7 +236,7 @@ if ($usernew = $userform->get_data()) { // save custom profile fields data profile_save_data($usernew); - // If email was changed, send confirmation email now + // If email was changed and confirmation is required, send confirmation email now if ($email_changed && $CFG->emailchangeconfirmation) { $temp_user = fullclone($user); $temp_user->email = $usernew->preference_newemail; @@ -249,7 +250,8 @@ if ($usernew = $userform->get_data()) { $emailupdatetitle = get_string('emailupdatetitle', 'auth', $a); //email confirmation directly rather than using messaging so they will definitely get an email - if (!$mail_results = email_to_user($temp_user, get_admin(), $emailupdatetitle, $emailupdatemessage)) { + $supportuser = generate_email_supportuser(); + if (!$mail_results = email_to_user($temp_user, $supportuser, $emailupdatetitle, $emailupdatemessage)) { die("could not send email!"); } }