Thanks for this great module - it makes it very easy to import data into profiles from a CSV file.

I am having one problem though - I imported a list of users and wanted to make their email address the login id, but the the generated username for an email like joe.smith@gmail.com ends up as
"joe smith@gmail com"
with spaces.

Is there any way to suppress this behaviour? I am using pathauto and set it to ignore characters like the dot.

Thanks in advance

Comments

mcsnolte’s picture

Looks like this is a problem with the function "_user_import_sanitise_username". It is running the following regex's:

// 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);

However, spaces are not allowed in Drupal usernames (only periods, hyphens, and underscores). This should probably be updated to something like:

// username cannot contain an illegal character
$username = preg_replace('/[^a-zA-Z0-9\.-_]/', '', $username);
// username should not contain multiple characters in a row
$username = preg_replace('/([\.\-_])[\.\-_]+/', '\\1', $username);

I'm not sure what the consensus is on multiple delimiters in a row, but my feeling is that you wouldn't want multiple periods, hyphens, and underscores in a row.

robert castelo’s picture

Status: Active » Fixed

Should be fixed in 5.x-2.0-beta1, please re-open this issue if you can still replicate the bug.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.