Username contains invalid characters - please use digits, letters or spaces

Discussion in 'Troubleshooting' started by alanpeto, Jan 21, 2009.

  1. alanpeto

    alanpeto New Member

    Joined:
    Dec 28, 2004
    Messages:
    29
    Vistor gets "Username contains invalid characters - please use digits, letters or spaces" when adding a period (.) to a username (such as first.last). I see in a few OLD posts that you change the following to include a period:

    PHP:
    if (preg_match('/[^0-9a-zA-Z_ ]+/'$vars['login'])){ 
            
    $error[] = "Username contains invalid characters - please use digits, letters or spaces";  

    but I can't find this anywhere in 3.0+ versions of amember...so is there some easy place just to change the code...or is this not possible anymore. What's curious is that this used to work, but no longer.

    Thanks!
  2. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    There was an overhaul in coding from 2.x to 3.x better to log a ticket to ask Helpdesk about this.

    Do let us know your findings :)
  3. zenpig66

    zenpig66 aMember Pro Customer

    Joined:
    Jan 1, 2009
    Messages:
    72
    What you are looking for is getLoginRegex at the bottom of common.inc.php. Looks like it was changed because of the added ability to turn off or on the inclusion of allowing spaces in usernames in the admin of AMember.

    Code:
     '/^[0-9a-zA-Z_]+$/D' :
     '/^[0-9a-zA-Z_][0-9a-zA-Z_ ]+[0-9a-zA-Z_]$/D';
    ..I believe should be changed to

    Code:
     '/^[0-9a-zA-Z_.]+$/D' :
     '/^[0-9a-zA-Z_.][0-9a-zA-Z_ .]+[0-9a-zA-Z_.]$/D';
    ...to allow periods. might want to doublecheck that with a support ticket but works, anyway :) you would then need to change the appropriate language file so it states the inclusion of periods to those signing up if you want.
  4. codeispoetry

    codeispoetry aMember Pro Customer

    Joined:
    Jan 12, 2009
    Messages:
    336
    Kudos to zenpig66 who found it!
  5. matthew_

    matthew_ New Member

    Joined:
    Jan 31, 2007
    Messages:
    10
    What about for version 4?
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    It is in /amember/application/default/models/User.php
    Check function getLoginRegex
    What you need to change here?
  7. matthew_

    matthew_ New Member

    Joined:
    Jan 31, 2007
    Messages:
    10
    I want to allow users to have the username to have a dash as in:

    user: Fred-Bloggs

Share This Page