Index: units/users/users_event_handler.php =================================================================== --- units/users/users_event_handler.php (revision 15215) +++ units/users/users_event_handler.php (working copy) @@ -1558,10 +1558,6 @@ $form_fields['Country']['options_sql'] = preg_replace('/ORDER BY (.*)/', 'ORDER BY IF (CountryStateId = '.$first_country.', 1, 0) DESC, \\1', $form_fields['Country']['options_sql']); } - $max_username = $this->Application->ConfigValue('MaxUserName'); - $form_fields['Username']['min_len'] = $this->Application->ConfigValue('Min_UserName'); - $form_fields['Username']['max_len'] = $max_username ? $max_username : 255; - // 2. set default user registration group $form_fields['PrimaryGroupId']['default'] = $this->Application->ConfigValue('User_NewGroup'); @@ -1596,7 +1592,11 @@ if ( $this->Application->ConfigValue('RegistrationUsernameRequired') ) { // Username becomes required only, when it's used in registration process + $max_username = $this->Application->ConfigValue('MaxUserName'); + $form_fields['Username']['required'] = 1; + $form_fields['Username']['min_len'] = $this->Application->ConfigValue('Min_UserName'); + $form_fields['Username']['max_len'] = $max_username ? $max_username : 255; } $this->Application->setUnitOption($event->Prefix, 'Forms', $forms);