I haven't been able to find any clear instructions for how to include roles & user pictures in the user migration using the migrate_d2d module.

I have found a number of links with some information, but it is all incomplete - or at least it is incomplete for someone who isn't a programmer...

The "Role Migration" page on Drupal.org (https://www.drupal.org/node/1819698) has as its first step: "Instantiate the appropriate role migration class."

Problem is, I have no idea how to do that...

I've tried to find examples of doing this but have found none.

The Migrate_d2d module has some example code in it that does a pretty good job of describing how to import users, vocabularies, nodes, & menus, but it is silent on how to bring along roles - which is vital to getting most of the rest of a site to work.

I need some help. Every source I've found seems to assume one or two things I just don't know - or maybe I do, but don't understand how to apply them in this case. Any specific, full examples - not the snippets I've seen a bunch of that don't give enough context - of how to get the user import to include role mappings would be greatly appreciated.

1 Answer 1


The following block of code allowed me to import user pictures, roles, & users, and connected them all properly:

   * User Picture Migration
  $api['migrations']['UserPictures'] = $common_arguments + array(
    'description' => t('Migration of user pictures from Drupal 6.'),
    'class_name' => 'DrupalPicture6Migration',
    'default_uid' => 1, // The default owner id if owner is not present
    'source_dir' => 'http://www.example.com',
    'destination_dir' => 'public://',

   * Register the role migration
  $api['migrations']['UserRoles'] = $common_arguments + array(
    'description' => t('Import Drupal 6 roles.'),
    'class_name' => 'DrupalRole6Migration',
    'role_mappings' => array(
      'unconfirmed' => 'unconfirmed',
      'contributor' => 'contributor',
      'superadmin' => 'superadmin',

   * Register the user migration.
  $api['migrations']['Users'] = $common_arguments + array(
    'description' => t('Migration of users from Drupal 6'),
    'class_name' => 'DrupalUser6Migration',
    'picture_migration' => 'UserPictures',
    'role_migration' => 'UserRoles',

I looked at probably 30-40 different search results - and some let's-see-what-this-does stabs in the dark - before I finally got things working, but there were 3 main resources I used:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.