How to migrate custom user fields to Drupal 7? I would like to migrate custom user fields from an external USER database table to the custom tables of Drupal 7.

I created custom fields for my users (First Name, Last Name, ...) under administration/configuration/account settings and I can confirm that these fields are created if I go to administration/people/ and click "edit" next to each user.

I also know that for each individual custom field that I have created, D7 created a new table of the form "field_data_field_[FIELD_NAME]" (ie. field_data_field_first_name, field_data_field_last_name, ...)

The specific commands I would like to find more information about are:

MigrateDestinationUser::getKeySchema();
$this-&gt;destination = new MigrateDestinationUser();


I understand the above command is the default used to import users to the default "users" database.

How can I migrate my content to another D7 table? Such as migrating the First Name from the external table to field_data_field_first_name?
An example migration is here (not my own) and there are some followup comments in that GIST:
https://gist.github.com/893241

What you are talking about is mapping old fields of data to new fields of data in drupal.

You do this by calling addFieldMapping() in your Migration class constructor. The migration __constructor() function typically has 3 big pieces.


Where is the data from. Your $this->source() SQL query.
What fields map from what to where -- per field.
Is there any default values or further cleanup needed of data. By using addField('new_drupal_field', 'old_value')-&gt;default('is_published', TRUE); or for instance addField('new_drupal_field', 'old_value')-&gt;seperator(',') for more than 1 entry per row.


See documentation on these pages:


MAPPINGS
Examples of Field Mappings
Advanced Field Mappings


The whole migration class, and more importantly its constructor, is basically a recipe of what drupal does per-row of the migration.

So after you have your source $query (basically a SELECT field1, field2, field3 from OLD_TABLE) you call the following:

// this is like saying field_first_name = old_field1 
$this-&gt;addFieldMapping('field_first_name', 'old_field1');