Notifications
Clear all

[Solved] Is there no character limit for usernames during registration?

3 Posts
2 Users
0 Reactions
134 Views
Posts: 12
Topic starter
(@plaka37)
Eminent Member
Joined: 4 weeks ago

Is there no character limit for usernames during registration? I tried 40 characters and it registered. Probably even more. This is a big problem. I think it's possible to register with a 100-character username.


2 Replies
Sofy
Posts: 5733
 Sofy
Admin
(@sofy)
Support Team
Joined: 8 years ago

Hi,

User registration and account creation are part of the WordPress core. wpForo only provides the registration form with different design and URL.

This is a native WordPress function, so you should look for a solution in WordPress itself.

Try searching for something like: “limit username in WordPress registration”.


Posts: 12
Topic starter
(@plaka37)
Eminent Member
Joined: 4 weeks ago

I solved the problem. 

 

The limit is set to a minimum of 3 and a maximum of 15 characters. You can change this if you wish. Add this to the functions file:

 

add_filter('registration_errors', function ($errors, $sanitized_user_login, $user_email) {

$length = mb_strlen($sanitized_user_login, 'UTF-8');

if ($length < 3 || $length > 15) {
$errors->add(
'username_length_error',
'Kullanıcı adı 3 ile 15 karakter arasında olmalıdır.'
);
}

return $errors;

}, 10, 3);