I'm trying to get Profile2 profiles imported for imported user accounts on my site, but I found the Profile2 example to be a little too simplistic to be helpful. Right now, I first import all the users (the basic data like name, password, email, etc.), and then I'd like to import all the Profile2 profiles for these imported users.

There's a migrate_map_user table in the old database from which I'm importing that holds the source->destination mapping, and I want to use that for when I'm importing Profile2 profiles. This way the profiles would be attached to the new users that were created during the first User import.

Does anyone have an example of how this would work? Am I simply missing something obvious here?

(Also, to the project maintainer - you might want to add a Profile2 component for issue components, as it's not in the list currently).

#7 a_wusel_migration.zip3.22 KBwusel
Members fund testing for the Drupal project. Drupal Association Learn more


mikeryan’s picture

Component: Migrate Extras Features » Profile2
Status: Active » Fixed

It is easier than you're imagining. If your user migration class was named MyUserMigration, and the source system's user ID in your profile query is USERID:

    $this->addFieldMapping('uid', 'USERID')
mikeryan’s picture

Oh, you probablly want to also throw in:

    $this->addFieldMapping('revision_uid', 'USERID')
geerlingguy’s picture

Perfect! I had that set to a defaultValue of uid 1, as I didn't realize Profile uses that field to link the profile to the user. Silly me... And thanks for adding the component!

[Edit: Part of my confusion comes from the fact that the UID label is "Profile2: Authored by (uid)" in the Migrate interface, and I presumed that was arbitrary. It might be nice to update the string to say "uid" instead of authored by...]

bryancasler’s picture


Status: Fixed » Closed (fixed)

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

wusel’s picture

Status: Closed (fixed) » Active

Thank you for your tipps #1 and #2.

Migrate and Migrate Extras are wonderful modules! Thank you very much!

In my import-module I get an error message:
'USERID used as source field in mapping but not in list of source fields'

Where / How can I find the correct text for 'USERID' for my import-module, to connect the profile-entries to the correct user?

The code of my import-module you find at

I use:
Drupal core 7.8
Administration menu 7.x-3.x-dev (2011-Aug-14)
Entity API 7.x-1.x-dev (2011-Sep-08)
Migrate 7.x-2.2
Migrate Extras 7.x-2.x-dev (2011-Sep-19)
Profile 2 7.x-1.0
Views 7.x-3.x-dev (2011-Sep-19)

Please help me.
Thanks in advance

wusel’s picture

Title: Better Profile2 Migrate Example? » please find the error in "Profile2 Migrate Example"
Priority: Normal » Major
3.22 KB

There is an error in the cookbook-example:
I attach the code of this module and the CSV-file.

The error:
When I have done the two migration steps, there are no entries in the profile2-fields of the three new users.

I think the second migration step can not build the connection from the profile2-fields to the respective user.

What is wrong?
Can somebody help me, to avoid that error?

Thanks in advance

wusel’s picture

Title: please find the error in "Profile2 Migrate Example" » Better Profile2 Migrate Example?
Status: Active » Closed (fixed)

I found and removed my error.

The cookbook-page is now ok:

Don't use the Attachment in #7 (has wrong code)!