global $CFG;
if (empty($user->username)){
$err->username = get_string("missingusername");
- }else{
+ } else{
$user->username = trim(moodle_strtolower($user->username));
if (record_exists("user", "username", $user->username)){
$err->username = get_string("usernameexists");
- }else {
- $string = eregi_replace("[^([:alnum:])]", "", $user->username);
- if (strcmp($user->username, $string))
- $err->username = get_string("alphanumerical");
+ } else {
+ $string = eregi_replace("[^(-\.[:alnum:])]", "", $user->username);
+ if (strcmp($user->username, $string)) {
+ $err->username = get_string("alphanumerical");
+ }
}
}