Join Us!

Love #WebDesign? We'll give you tips and tricks you can action TODAY!

Webdesign

Joomla Plugins

#16 - Change characters allowed in Joomla usernames

#16 - Change characters allowed in Joomla usernames

Version: Joomla 1.0.x

By default, Joomla does not allow certain characters to be used in usernames (e.g. hypens, brackets, square brackets etc.). This is done for good reasons, especially security. However, sometimes for different reasons, you will need to allow certain usernames. To change the characters allowed by Joomla you need to change the core code as described below.

You will need to edit several core files. Always make sure you have a full backup of the original source code before doing any changes. Also remember that any update will cause these changes to disappear, so make sure to keep track of the changes you have done. My personal way of doing this is to create a hacks.txt file, with the exact file changed, the code before and the code after, which is stored both locally and on the webserver, ideally in a hidden folder.

Changes to core code

In the example below we are removing just the hyphen character. We are simply removing the hyphen \- from the regular expression which searches for invalid characters. The \ is an escape character, whilst the pipe is used as a delimeter, so both have to be removed as well.

File: includes/joomla.php
From:

if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", $this->username) || strlen( $this->username ) < 3) {
   $this->_error = sprintf( addslashes( _VALID_AZ09 ), addslashes( _PROMPT_UNAME ), 2 );
   return false;
  }
  
To:
if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+]", $this->username) || strlen( $this->username ) < 3) {
   $this->_error = sprintf( addslashes( _VALID_AZ09 ), addslashes( _PROMPT_UNAME ), 2 );
   return false;
  }

File: components/com_user/user.html.php
From:
var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");

To
var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+]", "i");

File: administrator/components/com_user/admin.users.html.php
From:
var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");

To:
var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+]", "i");

That's it. You should now be able to register a new user without a hyphen.

PS. Remeber to backup before doing any core code changes.

Want to supercharge your website?

  Our website loads FAST ... just 1.29 seconds. We're hosted on FAST InMotion servers We want YOUR website to be fast too, so we've gotten you an exclusive deal - 47% OFF for DART Creations friends + FREE domain! Check it out NOW!

Translate

Follow us on Social

     

 

Where are we hosted?

This site is proudly powered by FAST VPS InMotion Servers and given an insane speed thanks to MaxCDN!

Web Hosting MaxCDN - Speed up your website

 

InMotion Hosting Review - Recommended Web Hosting servers for business, Joomla, WordPress and ecommerce websites.

inmotion Hosting Review

Advertise on DART-Creations.com

DART Creations is interested in developing partnerships with mutual benefit. If you like the stuff we publish and would like to develop a relationship, we'd be happy to hear from you. Go on - drop us a line - we'd love to hear from you :-)

The SUMMER DESIGN Bundle

27 premiums fonts, 91 graphic packs for  $29. Get it NOW - May Only!

summer design bundle

New! DIVI 2.7 WordPress TeMPLATE + PageBuilder

You'll surely create a perfect website with Divi 2.7!

Divi WordPress Theme