× Joomla Facebook Connect support forum

Topic-icon How to disallow spaces in usernames during registration?

Active Subscriptions:

None
In the default.php file how do we check the username entered during registration and reject any username where a space is entered into the username field? Some of my components link to domainname.com/username and usernames with spaces cause issues (404 pages). Any ideas?

Thank you!
The topic has been locked.
Support Specialist
You could add a Javascript check in the default.php, which we can help you do as well, but that won't prevent someone from proceeding with a space in their name anyways. You can make the following change and you should be good to go though:

In /components/com_jfbconnect/libraries/facebook.php, at line ~34, you'll see where we fetch the username that was entered. After that, put:
if (strpos($username, " "))
{
  $app->enqueueMessage("No spaces in username!!");
  $app->redirect(JRoute::_('index.php?com_jfbconnect&view=loginregister', false));
}

Let us know if that works for you or if you run into other issues, and good luck!
The topic has been locked.
Active Subscriptions:

None
Thanks, Alzander.

I looked at that file around line 34 but did not recognize a reference to a username check. Could I have an outdated file, maybe? I believe the first reference I saw was on somewhere between 100 and 200. If possible could you post the line of code under which this modification should appear?

Thank you!
-Moni
The topic has been locked.
Support Specialist
Moni,
Very sorry, I lead you astray. The correct file to look in is /components/com_jfbconnect/controllers/loginregister.php. Everything else above should (hopefully) be accurate.

Best of luck!
The topic has been locked.
Active Subscriptions:

None
Works wonderfully! Thank you very much!

-Moni
The topic has been locked.
Support Specialist
Moni,
Very glad to hear it, and sorry for the confusion earlier. If you continue using JFBConnect, please consider leaving a rating and view on the JED:
extensions.joomla.org/extensions/social-...ook-integration/7215

Thanks, and good luck with your site!
The topic has been locked.
Active Subscriptions:

None
Thank you. Review submitted. Great extension!

-Moni
The topic has been locked.
Support Specialist
Thanks so much Moni, and glad we could help. Should you need anything else, you know where to find us! :)
The topic has been locked.
Active Subscriptions:

None
Hello,

I got this problem too, tried to add the code as your solution but not work, i still can create username with space, and password lengh dont need to more than 6 char.

How can i fix this :(
The topic has been locked.
Support Specialist
Binh,
That's the right code. Please check that you've implemented it as stated. That code basically checks if the user's name has a space in it, and if so, redirects them back to the page to enter their username/email/password.

Make sure you put this after the line where we set $username = JRequest...

Good luck,
Alex
The topic has been locked.