I'm writing a migration script from Mambo to Drupal. The mos-users (Mambo) to users (Drupal) table translation is pretty straightforward.

The Drupal user table, however, has a field called "data" and formats something like this:

a:1:{s:5:"roles";a:1:{i:0;s:1:"2";}}

I notice that it also stores private message module flags when that's in service.

Will I need to initialize that field to anything when I dub the data to the Drupal database, or can I just leave it blank?

Where, in the Drupal documentation, is the syntax for the user.data field discussed?

CLE

Comments

nevets’s picture

If you are doing the script from within Drupal I would construct a user array, populate it and call user_save(). One way to do this is copy the mambo user table into the drupal database (you may need to change the table name).

Then using code running in drupal, loop through each record and make a call to user_save(). Here is the call I used in a similiar situtation.

$account = user_save('', array('name' => $user_name, 'pass' => $pass, 'mail' => $email, 'roles' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)));

The values $user_name, $pass, $email all came from the old user data.

CLamont’s picture

I've seen a reference to that approach--copying foreign tables into Drupal, then manipulating the data.

So far I've chosen to write a freestanding PHP script. I have the get-the-data-from-Mambo part pretty far along, and am working on the INSERT INTO part now.

I'll keep the alternative in mind, though.

I'd still like to know if I need to put something in the users.data field, though.

Curtis