× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can not signin with username is number
If the username is number example: (123456), I can not login.

help me! thanks
I can confirm this. I just tried and a username of
123456 does not work but a username beginning with a number, does (ie 1user).

Investigating now.
I'm kind of at a loss right now on that one. It's obvious that an initial problem was that if a username is numeric, it looks up the user by their id. I fixed that on my system and can get it to find a user, but I cannot get a user with a purely numeric username to login. I'll keep looking when my eyes are fresher. Sorry about that. I've never come across this issue.
Thanks you for sppport
The problem is (was?) in User::find().

Code such as this will solve the problem:

if (is_numeric($user) && $user < 10000) {
} else {

(Sent previously in PM to mudmin, including here for documentation purposes)
Good call on that one.
Hello! Thank you for this excellent framework!
I got this same problem, I need the username to be just numbers (the personal ID of students) and the numbers may be between 11000000 and 50000000. I create the users but I can't log in. Is this already solved or is a fact that the framework cannot handle purely numeric usernames to login?
Thank you!!
There is a trick to it. Because the system will allow you to use your user id instead of username or email, it's looking for the user id. Maybe the best thing.

This is one of the VERY rare times I would tell you to just edit a system file.

If you look at line 57 of users/classes/Users.php you'll see that if the username is numeric, it is looking in the id field.

Change that to username.

You'll obviously have to test it, but that should do the trick. Then just look out for updates that update the user class which is REALLY rare.
I tried but now I can't log in with any user. Maybe I have to modify Validate class? And I don't know where to activate an error log to see what is wrong at login time.
Thank you for your time!
Even more, I commented the IF lines on User.php like this:
public function find($user = null){
if ($user) {
$field = 'id';
}elseif(!filter_var($user, FILTER_VALIDATE_EMAIL) === false){
$field = 'email';
$field = 'username';

So this function assigns $field = 'username' without a doubt. And the behavior is the same, can't log in with any user.

Forum Jump:

Users browsing this thread: 1 Guest(s)