MDL-30948 do not generate new passwords for suspended accounts because they would...
[moodle.git] / lib / cronlib.php
index a2ab61e..83978d6 100644 (file)
@@ -212,8 +212,9 @@ function cron_run() {
                                                  p.id as prefid
                                             FROM {user} u
                                             JOIN {user_preferences} p ON u.id=p.userid
-                                           WHERE p.name='create_password' AND p.value='1' AND u.email !='' ");
+                                           WHERE p.name='create_password' AND p.value='1' AND u.email !='' AND u.suspended = 0 AND u.auth != 'nologin'");
 
+        // note: we can not send emails to suspended accounts
         foreach ($newusers as $newuser) {
             if (setnew_password_and_mail($newuser)) {
                 unset_user_preference('create_password', $newuser);