Hello guys,

I need some help for the drupal commerce kickstart online shop i'm creating.

I had to import clients from an old database and I used some scripts to do so. Everything works well with the users and even with the user profiles (addresses for commerce) but whenever Drupal is trying to display the username it shows nothing.

You can see on this capture that the admin user list correctly displays the users registered with the website but that the username stays blank for imported users.

Only local images are allowed.

The same occurs anywhere drupal wants to display the username.

However, when I edit users from the admin section, the username field is not empty.

Here is the code I use,

    $user = new stdClass();
    $email = strtolower($row['email']);
    $user->name = $email;
    $user->mail = $email;
    $user->init = $email;
    $user->access = time();
    $user->login = time();
    $user->pass = user_hash_password($row['pwd']);
    //$user->timezone = 'Europe/Paris';
    //$user->language = 'fr';
    $user->status = 1;
    $user->roles = array('2' => 'authenticated user');
    $user->field_observations['und'][0]['value'] = $row['observations'];
    $user->field_observations['und'][0]['format'] = 'full_html';
$user->date['mimemail_textonly'] = 0;
[…]
    user_save($user);

Except for this username issue, everything works great, users are created and all the fields are correctly filled.

Does anyone have an explanation for that ? I thank you in advance for your help. Ask if you need more informations in order to help me.

Comments

You can check for any validation applied to hook_user_presave() by any of the used module. As your code is tested and works on fresh drupal Installations.

subhransu sekhar

I checked and didn't see anything wrong…

When I programmatically get two users (one with the bug and one without) with user_load() and display the returned objects with print_r(), the filled data are exactly the same.

Is any data in users table field name?

The username is present for all the users

OK.

I found the reason thanks to TLyngeJ on the drupal IRC channel.

Kickstart uses customer profiles to store billing and shipping address. It seems that if a user has a customer profile, the "full name" field of this profile will be displayed instead of the username.

I don't use this field so it was left blank and nothing was displayed.