Upgrading a website from Drupal 6 to Drupal 7: migrating the users

One of our clients needs a website upgrade from Drupal 6 to Drupal 7. Here are the steps I took to export the users from the D6 site and import them into the D7 site.

Cloned our starter website to create a brand new Drupal 7 site

See Just Magic Design blog entry Recipe for starting a new Drupal project. For a variety of reasons, we wanted to start with a clean Drupal 7 site and migrate content over from the D6 site.

Set up Roles and Permissions in the D7 site

I referred to how the Roles and Permissions were set up on the D6 site (Admin > User Management > Roles), and set them to match on the D7 site (Admin > People > Permissions). This is a relatively short process which I did by hand. For our client website this required adding a new Role, that of Moderator, and setting the permissions for each of the 5 Roles appropriately.

The plan: use the Views Data Export module to export user data into a CSV or XML file, then import the user data using the Feeds module

  • On the D6 site, verified that the Views Data Export module was installed and enabled.
  • On the D7 site, installed and enabled the Feeds, Feeds Admin UI, Feeds Import, and Feeds XPath Parser modules.

I did not want to use the User Export module, as it did not export all the user data I needed.

Helpful websites which describe this process:

Thanks, Adelle and Vincent!

Set up User fields on D7 site

  • Determined what user information was stored on the the D6 site and needed to be implemented in the D7 site.
  • Referred to User Settings on D6 site (Admin > User Management > User Settings) and set them by hand on D7 site (Admin > Configuration > Account Settings) : signature disabled, picture enabled. Set picture path and maximum dimensions and file size.

The D6 site also used the Profile module to add additional user fields (Admin > User Management > Profiles).

This functionality was moved into Drupal core in D7, so on the D7 site I used Admin > Configuration > People > Account Settings > Manage Fields to add additional user fields.  No more Profile module!

Problems with exporting the User Picture

On the D6 site, I set up a View to export user data into a CSV file. I included all the user data, including the profile fields and the User Picture, as fields to include in the view.

Here's where I ran into the first problem with User Picture – exporting that field into a CSV file leaves the field in the CSV file blank. The picture showed appropriately in the view preview, but was blank in the CSV file. After research and googling, I found no way to get the Views and Views Data Export modules to include the picture or its link in the CSV file.

At this point I decided to try again using an XML file instead of a CSV file. I was encouraged by comment #5 in the Parsing Images with XPath Parser (https://drupal.org/node/1184292), where user Problue Solutions states “Surprisingly it works by just capturing the URL of the image in the xpath expression and mapping it to a regular imagefield. feeds_imagegrabber is not required.”

However, I was unable to isolate the link to the picture within an XML field. Drupal 6 does not allow me to isolate the picture link using [picture] replacement pattern.

Finally, I tried using the “Rewrite the output of this field” to contain the path to each user's picture, which was “path/files/pictures/picture-[uid].jpg”, where [uid] is the replacement pattern for the user id. However, this was not an appropriate solution either, as there were many users who did not have a picture, and Drupal did not recognize the picture field as empty when there was no picture, so I was always getting a link generated whether there was a picture there or not.

Finally, after way too much time spent researching this issue, and since there were only a few user pictures in the D6 site, I decided that the most efficient course of action was to stop beating my head against the wall with this problem and bring all the user pictures over to the D7 site by hand.

Export D6 users to an XML feed

Here's the view used to export the active users to XML:

I followed Adelle's detailed advice on setting up this view (see link to Adelle's blog above).

When I pointed the browser at the path containing the XML feed, (path/feeds/users/all/xml, specified in the Data Export Settings Path) I saw data in this form:

Import users from XML feed into D7 site

The Feeds Import module provides the example importer User Import. I cloned it and then modified the clone as needed. In D7 site, Admin > Structure > Feeds Importers > User Import > Clone.

  • Followed Adelle's advice re setting up the importer. Remember we are importing users, not nodes.

  • Mapped the XML fields to the User fields. Picked “XPath Expression” in the source dropdown and mapped that field to the correct User field. For example, in this case the 3rd XML field in the feed is <E-mail>, so I mapped it, represented by xpathparser:3, to the user Email Address field.

  • Went to path/import (where path is the website). From the table of available importers, chose the one just created.
  • Entered the URL of the XML feed. This is the path specified in the D6 site View Data Export (in this case, path/feeds/users/all/xml).
  • Expand edXPath Parser settings and filled them in. Again, mapped the XML fields to the user fields.

Clicked “Import” to import users!

If there is a problem with the imported users, you can bring up the importer and choose “Delete Items” from the import menu (your menu will look different as it will be styled by your own site theme).

Then tweak the View Data Export and Feeds Importer as necessary and try again.

Update user passwords in D7 site

Passwords were not brought over with the other user information, so users will not initially be able to log in to the D7 site. Users can request new passwords, login, and then set their own passwords.

All done

Now, wasn't that easy and straightforward. ;-) Good luck with your user migration!

About Jen Brown

Jen Brown's picture
Jen is a website and software developer at Just Magic Design. She has a degree in Computer Science from Yale University and loves problem solving. Jen’s other roles include violinist, knitter, humanist, and age-grouper triathlete. She lives in Massachusetts with her husband, her two sons, and their ever-so-cute canine companion, Lily the mutt. She loves snow, good science fiction novels, and Irish Breakfast tea.

Add your comment