diff -u -p -r1.5.2.5 email_registration.module --- email_registration.module 31 Mar 2009 21:32:13 -0000 1.5.2.5 +++ email_registration.module 5 Apr 2009 12:59:12 -0000 @@ -9,14 +9,7 @@ function email_registration_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case 'insert': - $namenew = preg_replace('/@.*$/', '', $edit['mail']); - // if username generated from email record already exists, append underscore and number eg:(chris_123) - if (db_result(db_query("SELECT count(*) FROM {users} WHERE uid <> %d AND LOWER(name) = LOWER('%s')", $account->uid, $namenew)) > 0) { - // find the next number available to append to the name - $sql = "SELECT SUBSTRING_INDEX(name,'_',-1) FROM {users} WHERE name REGEXP '%s' ORDER BY CAST(SUBSTRING_INDEX(name,'_',-1) AS UNSIGNED) DESC LIMIT 1"; - $nameidx = db_result(db_query($sql, '^'. $namenew .'_[0-9]+$')); - $namenew .= '_'. ($nameidx + 1); - } + $namenew = preg_replace('/[^a-zA-Z0-9.-]/', '_', $edit['mail']); // replace with generated username db_query("UPDATE {users} SET name = '%s' WHERE uid = '%s'", $namenew, $account->uid); break;