Generating lowercase usernames

new_B - October 22, 2008 - 19:28
Project:User Import
Version:5.x-1.3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

Regarding username generation, is there a way to set it so that the username is all lowercase? A user can log in (case insensitive username) but the username displayed in posts is in the format of first and last initials in uppercase and the rest in lowercase.

Current output: "John" + "Smith" => "JSmith".
Desired output: "John" + "Smith" => "jsmith".

Thanks.

#1

nicholasThompson - October 27, 2008 - 16:53

+ 1 for me....

Should be quite a simple patch in the sanitize username function...

#2

ambereyes - November 3, 2008 - 20:31

Make the following change in user_import.module

function _user_import_sanitise_username($username) {
 
// username cannot contain an illegal character
$username = preg_replace('/[^a-zA-Z0-9@ ]/', ' ', $username);
// username cannot contain multiple spaces in a row
$username = preg_replace('/[ ]+/', ' ', $username);  

// username must be less than 56 characters
$username = substr($username, 0, 56);

// username cannot begin or end with a space
$username = trim($username);

// username must be all lower case
$username = strtolower($username);

return $username;
}

Katrina

--
www.ambereyes.net

#3

Mel55113 - December 29, 2008 - 16:02

Actually I prefer the current mode of operation, e.g. John Smith becomes JSmith. I think it's much easier to read and gives a more polished look.

Since in use the username (or email address if you use login toboggan; highly recommended) is inherently case insensitive it really doesn't matter to the user at login time.

Therefore, if you implement this request, please make it optional.

Thanks,
Mel

 
 

Drupal is a registered trademark of Dries Buytaert.