Author Topic: Dash in username  (Read 208 times)

happy

  • Prime Member
  • ****
  • Posts: 128
  • Karma: +0/-1
Dash in username
« on: February 02, 2018, 02:02:56 AM »
Hi

I would like to allow dash (-) in username along with alphanumeric value.

like abcde-uvxyz as username

Please guide.

Thank you.

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3042
  • Karma: +210/-7
    • Maverick Webworks
Re: Dash in username
« Reply #1 on: February 02, 2018, 09:42:36 AM »
In the processors/join.php file look for the following on about line #39

Code: [Select]
if (!preg_match('/^[a-z0-9_]+$/',$input['user']) || strlen($input['user'])<4 || strlen($input['user'])>20) {
and simply replace this part [a-z0-9_]

with this [a-z0-9_-]

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

happy

  • Prime Member
  • ****
  • Posts: 128
  • Karma: +0/-1
Re: Dash in username
« Reply #2 on: February 03, 2018, 05:35:06 AM »
I followed your instruction but form is not submitting and got this message

'Please use only letters and digits for your username. 4-20 chars.'

Please guide

Thank you

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3042
  • Karma: +210/-7
    • Maverick Webworks
Re: Dash in username
« Reply #3 on: February 03, 2018, 06:57:27 AM »
I just assumed that it would work, but looking into it further it appears that dashes are treated as special characters and are not acceptable in usernames. The programming standards only allows usernames that contain letters, numbers and underscores.

Using dashes in usernames supposedly can potentially cause conflicts and issues. Even though you may come across a few sites on web that do allow dashes, it's really not recommended.

This is probably why the original developer created it without including dashes as it wasn't considered an acceptable standard.

Since I'm not exactly sure what needs to done to accomplish allowing dashes, and because of the potential issues, it's not something I care to purse, therefore unfortunately it appears that you're stuck just using underscores.

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3042
  • Karma: +210/-7
    • Maverick Webworks
Re: Dash in username
« Reply #4 on: February 05, 2018, 03:16:03 AM »
I think I've come up with a possible solution.

In the processors/join.php file look for the following on about line #39:
Code: [Select]
if (!preg_match('/^[a-z0-9_]+$/',$input['user']) || strlen($input['user'])<4 || strlen($input['user'])>20) {and replace it with this:
Code: [Select]
if (!preg_match('/^[a-z0-9]+(?:[\w \-]*[a-z0-9]+)*$/',$input['user']) || strlen($input['user'])<4 || strlen($input['user'])>20) {
Then in the js/general.js file look for the following on about line #161:
Code: [Select]
patn=/^[a-zA-Z0-9_]+$/;and replace it with this:
Code: [Select]
patn=/^[a-z0-9]+(?:[\w \-]*[a-z0-9]+)*$/;
This solution also doesn't allow dashes and underscores to be included at the start or end of a username, not only is it messy if they do it but it can cause possible issues especially if dashes are used.


You might also want to consider changing the error message so that users know everything that isn't allowed and what to check for.

In the admin go to 'Skin Settings', then click 'Translate', then scroll down to Key #63 and replace the existing error message with something like this:

Quote
Please use only letters, numerals, dashes and underscores for your username. Dashes and underscores can not be included at the start or end of your username. Must be 4-20 characters.

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

happy

  • Prime Member
  • ****
  • Posts: 128
  • Karma: +0/-1
Re: Dash in username
« Reply #5 on: February 06, 2018, 12:06:18 AM »
Hi maverick

I followed your instructions exactly and regenerated the skin but form is not submitting and shows same message 'Please use only letters and digits for your username. 4-20 chars'

you know if it works this will be a good feature.

Please guide

Thank you

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3042
  • Karma: +210/-7
    • Maverick Webworks
Re: Dash in username
« Reply #6 on: February 06, 2018, 12:47:51 AM »
It does work, I've tested it and it's working just fine for me. I even created a new test member using a dash (test-member).

The steps that I provided only requires changing 1 line of code to 2 files and changing the message in the admin, which is a pretty simple and straight forward modification, so I'm not sure how or where you went wrong,

Make sure you've made the changes to the js/general.js file, this is important or it won't function properly.

If the message isn't changing then you're not doing something right in the admin.
When you make the changes for the new message in the admin 'Skin Settings' >> 'Translate' section, after you change the message in the #63 field make sure you click the save button at the bottom of the page. Then Regenerate your skin.

If you still don't see any change try clearing your browser cache.

I don't know what method you're using to edit the processors/join.php and js/general.js files. The ideal and proper method would be to edit them on your PC from a back up of all your files and then upload (FTP) them to your server. Try checking these 2 files on your server to make sure they contain the changes.

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

happy

  • Prime Member
  • ****
  • Posts: 128
  • Karma: +0/-1
Re: Dash in username
« Reply #7 on: February 07, 2018, 01:11:25 AM »
Hi Maverick

I am sorry its not working on my PC, I have Windows 7 Ultimate SP1 32-bit, XAMPP Version: 5.6.31 with PHP 5.6

I checked it several times removed cache, regenerated skin, checked both processors/join.php and js/general.js  files carefully, but same error message.

I am not able to understand whats mistake i am making.

Please guide

Thank you

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 3042
  • Karma: +210/-7
    • Maverick Webworks
Re: Dash in username
« Reply #8 on: February 07, 2018, 09:00:14 AM »
The change to the actual error message is done in the admin Skin Settings.

As far as it not functioning by allowing a dash in the username, that is totally reliant on the processors/join.php and js/general.js  files.

I've tested it on my local WAMP server running PHP 5.4, the PC and windows version your testing with should have nothing to do with it.

However, I'm not sure if this has anything to do with it but your PHP version is too high. Etano will not function properly using PHP 5.6 and up. If your running PHP 5.6 I'm surprised you're not having more issues with the script.

http://www.datemill.com/etano/wiki/doku.php?id=requirements


Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.

happy

  • Prime Member
  • ****
  • Posts: 128
  • Karma: +0/-1
Re: Dash in username
« Reply #9 on: February 07, 2018, 11:10:26 PM »
Hi Maverick

There is no issues running etano on PHP 5.6 except may be this dash issue.

Any way thanks for your support.