Форуми / Cotonti / Support / [solved] Prevent spaces and extra letters in user name?

tensh
#1 06.11.2012 07:49

How to create a filter during registration, preventing user to create usernames with spaces or forbidden letters (like & or "')?


Відредаговано: tensh (06.12.2012 09:05, 11 років тому)
Kilandor
#2 06.11.2012 11:09

You will need to create a plugin that hooks into users.register.add.validate and then you may check for any characters you don't want and then present an error

Macik
#3 06.11.2012 11:11

It needs simple plugin creation with «hooked» on users.register.add.validate

With several lines of actual code:

$L['aut_notallowedname'] = 'Only letters, digits, hyphen, underscore allowed for User name ';
if (preg_match("/[/s&\'\?\"]/", $ruser['user_name'])) cot_error('aut_notallowedname', 'rusername');

Where «[/s&\'\?\"]» set of unallowed symbols.

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
tensh
#4 07.11.2012 12:51

Thank you very much :)