Skip to main content
Topic: Shorten user names (Read 3349 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Shorten user names

Hello!

Is there a possibility, to keep the usernames short, when people are using the registerform?
They should not be able to type more than a maximum of 14 characters for their usernames.

Last Edit: June 09, 2016, 06:09:58 am by Ruth

Re: Shorten user names

Reply #1

All the username validation is done in Auth.subs.php function validateUsername.
The first check is length that is set to 25, if you want to force them down to 14 you can change the 25 to 15.
I'm not sure at the moment it can be done without modifying the code, but looking at that function is a nice spot for some changes. O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: Shorten user names

Reply #2

Thank you very much, Emanuele.

I have tried this, but it is still possible to type 25 characters into the field.


Re: Shorten user names

Reply #4

Quote from: Ruth – I have tried this, but it is still possible to type 25 characters into the field.
But they should get a "registration error".
Bugs creator.
Features destroyer.
Template killer.

Re: Shorten user names

Reply #5

Yes, they will get an error message. It is working fine that way. (I did not try to finish the registration first.) O:-)

I have changed this string $txt['error_long_name'] in Errors.german.php a little, to tell them, that their usename may not have more than 14 characters.

But it would be better to tell them about this, before they will get an error, in the registerform itself.  Can I add something there to "Username"?

This string in index.german.php $txt['username'] = 'Benutzername'; is not only used while you register, it is also used for the login, as I believe?

Re: Shorten user names

Reply #6

Can I add a little text here in Register.template.php for explaining?

Code: [Select]
	echo '
<form action="', $scripturl, '?action=register2" method="post" accept-charset="UTF-8" name="registration" id="registration" onsubmit="return verifyAgree();">
<h2 class="category_header">', $txt['registration_form'], '</h2>
<h3 class="category_header">', $txt['required_info'], '</h3>
<div class="windowbg2">
<input type="password" name="autofill_honey_pot" style="display:none" />
<fieldset class="content">
<dl class="register_form">
<dt>
<strong><label for="elk_autov_username">', $txt['username'], ':</label></strong>
</dt>
<dd>
<input type="text" name="user" id="elk_autov_username" size="30" tabindex="', $context['tabindex']++, '" maxlength="25" value="', isset($context['username']) ? $context['username'] : '', '" class="input_text" placeholder="', $txt['username'], '" required="required" autofocus="autofocus" />
<span id="elk_autov_username_div" style="display: none;">
<a id="elk_autov_username_link" href="#">
<img id="elk_autov_username_img" src="', $settings['images_url'], '/icons/field_check.png" alt="*" />
</a>
</span>
</dd>

A break after this?
Code: [Select]
<strong><label for="elk_autov_username">', $txt['username'], ':</label></strong>


Re: Shorten user names

Reply #7

Quote from: Ruth – This string in index.german.php $txt['username'] = 'Benutzername'; is not only used while you register, it is also used for the login, as I believe?
I guess so, honestly I don't remember, but considering how general it is, it's likely used in many places. :)

Quote from: Ruth – Can I add a little text here in Register.template.php for explaining?
Why do you ask me if you can? :P
Of course you can.
Bugs creator.
Features destroyer.
Template killer.

Re: Shorten user names

Reply #8

Because I am a big coward and don't want to do any mistake in the files.

I was not sure about it, therefore  I asked.

Re: Shorten user names

Reply #9

Code: [Select]
<input type="text" name="user" id="elk_autov_username" size="30" tabindex="', $context['tabindex']++, '" maxlength="25" value="', isset($context['username']) ? $context['username'] : '', '" class="input_text" placeholder="', $txt['username'], '" required="required" autofocus="autofocus" />
In that line, just change maxlength=25 to maxlength=14.

Re: Shorten user names

Reply #10

Thank you very much, Frenzie. I changed it in this line now.