How to set a minimum username length of 6 characters for all users except administrators and staff?

AI-generated summary

The discussion revolves around setting a minimum username length of 6 characters for regular users in Discourse, while allowing administrators and staff to use shorter usernames. sasha_ilinsky initially asked if this can be achieved with a simple JavaScript check. pfaffman suggested changing the minimum username length, setting the admin username, and then changing it back, but Firepup650 pointed out that this would cause issues due to existing users with shorter names.

sasha_ilinsky emphasized the need for a client-side solution that prevents regular users from entering fewer than 6 characters, while allowing administrators to enter shorter usernames through the admin panel. pfaffman acknowledged the complexity of the issue and suggested that having everyone use 6 letters might not be so bad after all. sasha_ilinsky is looking to create a theme component using JavaScript to achieve this functionality.

Hello,

How can I set a minimum username length of 6 characters for regular users in Discourse, while allowing administrators and staff to use usernames of 3 characters? Can this be achieved with a simple JavaScript check?

Thanks in advance!

Change the minimum, set the admin username, change the minimum back. It’s not going to happen very often. If you enforced a minimum with javascript then it would be possible to bypass the check.

Wouldn’t that cause issues? The min username length setting advises that:

WARNING: if any existing users or groups have names shorter than this, your site will break!

Oh. Darn. I guess that won’t work. Maybe just having everyone use 6 letters isn’t so bad?

We need users on the client side to be unable to enter fewer than 6 characters when filling out a form. However, administrators should be able to enter fewer characters through the admin panel. Security concerns are not important here, as we can manually fix any issues if someone bypasses this check.

If you could advise where to look in terms of JavaScript, I will try to create a theme component out of this.

Just imagine how cool it would be: limiting users in characters without breaking the system. It’s so simple, why hasn’t it been done yet?