diff --git a/lib/cronlib.php b/lib/cronlib.php index 49830c70f5d..37e09bae47e 100644 --- a/lib/cronlib.php +++ b/lib/cronlib.php @@ -223,8 +223,9 @@ function cron_run() { // Generate new password emails for users - ppl expect these generated asap if ($DB->count_records('user_preferences', array('name'=>'create_password', 'value'=>'1'))) { mtrace('Creating passwords for new users...'); - $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.firstname, - u.lastname, u.username, u.lang, + $usernamefields = get_all_user_name_fields(true, 'u'); + $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, + $usernamefields, u.username, u.lang, p.id as prefid FROM {user} u JOIN {user_preferences} p ON u.id=p.userid