Changing username in user profile not working?

Discussion in 'Troubleshooting' started by tomfra, May 17, 2008.

  1. tomfra

    tomfra Member

    Joined:
    Dec 21, 2006
    Messages:
    199
    I've just enabled updating / changing usernames in the user profile - i.e. so that the users can change the automatically generated usernames to something else.

    But when I enter a new username in there and click the "Save profile" button, I get this error message:

    "Please enter correct username: Please enter correct login. It must contain at least 4 letters, digits or _".

    The new username is completely OK - not used by anyone else, having 4+ characters etc. I am looking at the code and I can hack it to make it work for sure but perhaps I am missing something?

    Has enyone experienced the same problem? I will submit a support request to Alex on Monday if I don't find a solution.

    Tomas
  2. toadspittle

    toadspittle New Member

    Joined:
    May 23, 2008
    Messages:
    15
    I'm having this problem, too. Any resolution?
  3. tomfra

    tomfra Member

    Joined:
    Dec 21, 2006
    Messages:
    199
    I submitted a support ticket, send the support staff my FTP info and they fixed it. I am just looking at the profile.php file to see what they changed there.

    Although I am not completely sure this is the change, try commenting out or deleting this code:

    PHP:
        if (!preg_match($p="/^\\w\{{$config[login_min_length]}}\\w*\$/"$login)){
            return 
    sprintf(_MEMBER_PROFILE_CORRECTLOG$config[login_min_length]);
        } else if (!
    $member_id=$db->check_uniq_login($login)){
            return 
    sprintf(_MEMBER_PROFILE_NAMEEXISTS$login);
        }
    ...which should be on lines 41-46. If that doesn't work, ask Alex. I don't want to append the whole profile.php file here as it's licensed.

    Tomas
  4. netserv3

    netserv3 aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    21
    I also faced this problem. I managed to solve it. There is an error in regular expression in profile.php file.

    1. Open amember/profile.php file in text editor.
    2. Search for the following line:

    PHP:
    if (!preg_match($p="/^\\w\{{$config[login_min_length]}}\\w*\$/"$login)){
    3. Change it to:

    PHP:
    if (!preg_match($p="/^\\w{{$config[login_min_length]}}\\w*$/"$login)){
    4. or change it to the following line, which checks login max length also:

    PHP:
    if (!preg_match($p="/^\\w{{$config[login_min_length]},{$config[login_max_length]}}$/"$login)){
    I am sure this will solve your problem.

Share This Page