Forums / Cotonti / Support / [solved] Prevent spaces and extra letters in user name?

tensh
#1 2012-11-06 07:49

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

This post was edited by tensh (2012-12-06 09:05, 11 years ago)
Kilandor
#2 2012-11-06 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 2012-11-06 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 2012-11-07 12:51

Thank you very much :)