Commit 4b4af206 authored by Chris Herberte's avatar Chris Herberte

#401890 fix to remove unwanted characters from generated name

parent b108e2a5
......@@ -24,6 +24,9 @@ function email_registration_user($op, &$edit, &$account, $category = NULL) {
if (empty($names)) {
// Default implementation of name generation
$namenew = preg_replace('/@.*$/', '', $edit['mail']);
// Remove unwanted characters
$namenew = preg_replace('/[^a-zA-Z0-9.-]/', '', $namenew);
// 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment