I want to require that usernames be one word, no spaces, no punctuation. Can I do that without diving into the code?

I have wildcard dns, mod_rewrite and mass_url playing nicely together, so username.example.com redirects to www.example.com/blog/username (which is then handled by mass_url). Very cool.

But not if somebody registers as "John Q. Public."

Comments

Steven’s picture

You should be able to use usernames like that, as long as you urlencode them, like this:

/blog/John%20Q.%20Public

The query handling in PHP will convert this to plain data before it reaches the code, so it'll work fine.

Otherwise, you'll have to modify user_validate_name() in user.module...

--
If you have a problem, please search before posting a question.

yelvington’s picture

I think I managed to implement the policy in administer->access control->account rules:

deny % %
deny %.%
deny %,%

et cetera. However, the user prompt needed to be changed as well, and it seems to be hardcoded/not changeable through the admin interface. I edited modules/user.module, which naturally will be nuked next time I upgrade. :-)

I guess I should file a feature request.

Walt Esquivel’s picture

Hi,

I've noticed that when a new user registers on my Drupal-powered web site, he or she need only enter a single letter or number to do so.

How can I require all new users to sign up with a username of at least, say, 5 characters? For example, "abcde" instead of just "a".

Thank you so much in advance,
Walt

jdecker’s picture

Follow the same technique that you saw above in setting wildcard rules, e.g. for the username, deny
_____

(That's four underscores, which means no less than five characters.)

yeeloon’s picture

It seems that I can only set a minimum of __ (two underscores) DENY __ in my Access rules. Beyond that (by adding more than 2 underscores), my registration page doesn't even prompt me the errors or highlighted cell for that username field.

I'm running on Drupal 5.2 together with LoginToboggan module. Even with it disable, it still the same problem as described above.

Is this a core problem or some minor bugs... can somebody shed some light on this? Or should I add in more rules?

Thanks in advance!

olalindberg’s picture

If someone looks for this as long as me; the path for this is admin/user/rules