I'm using nodeprofile on a few of the sites I maintain, and recently needed to import a large number of users into one of these sites.

user_import currently supports mapping CSV fields into Drupal's core profiles, but not into nodeprofile CCK fields.

I hacked user_import to support nodeprofile, and have attached my diff from the user_import-5.x-1.x-dev. This code solved my problem, but is at best alpha-quality and leaves a lot of unaddressed issues... but may be a useful start.

Currently this patch does the following:

  • Implements _user_import_nodeprofile() which, similar to _user_import_profile(), returns an array of available fields to be mapped by the user. My implementation handles cases where there are multiple nodeprofiles available and generates decent unique names for all CCK fields on all nodeprofiles. It includes specialized support for cck_fullname and cck_address, breaking their multi-part data into separate mappable fields.
  • Implements _user_import_save_nodeprofile() which takes the fields and generates corresponding nodeprofiles. Nodeprofiles are only created for contenttypes which CCK fields that have actually been mapped by the user, not for all nodeprofile contenttypes.
  • Modifies _user_import_process() to call either _user_import_save_profile() or _user_import_save_nodeprofile() or both, depending on which modules are enabled.

Currently this patch doesn't do the following:

  • Multiple-value CCK fields, except for the "text" field type
  • Report errors decently. If CCK field validation fails, the entire nodeprofile creation may fail silently. (This wasn't a problem for me because my CSV data was pretty well-cooked prior to the import. YMMV.)
CommentFileSizeAuthor
user_import-nodeprofile.patch11.76 KBsmokris

Comments

mlncn’s picture

I hereby nominate smokris for Drupal Hero of the Month (TM)

Also, this patch applied cleanly to User Import's 5.x-1.3 release, which I think is identical to development at the moment.

benjamin, Agaric Design Collective

najibx’s picture

I am using Bio as oppose to nodeprofile.

i don't normally cross posting (http://drupal.org/node/211602#comment-723294), but looking at your patch, I realize that such integration with bio module is not as simple. Any tips?

tomhung’s picture

Any idea on including the LDAP field "LDAP User DN:" as well?

afinke’s picture

Thanks so much for this patch, it was just what I needed. One issue/question, and I don't know if this is specific to the nodeprofile patch, or also true for User Import in general: Token replacement does not seem to work for imported nodeprofiles.

That is, I'm using Auto Nodetitle to set the nodeprofile node title to the value of one of my CCK fields. The token replacement in Auto Nodetitle works fine when adding the node via the normal edit form, but when I import a user using User Import, the created nodeprofile's title is set to the field name rather than the value, i.e., the replacement doesn't happen. Any guidance as to an easy way to make this happen? This may be a question better put to the Token module author, but I thought I'd start here. Thanks.

hansrossel’s picture

I have the same problem, all nodeprofile titles are "ant". There is an issue for auto nodetitles (http://drupal.org/node/218634) that points to http://drupal.org/node/148530 as the problem.

When I edit and save manually a nodeprofile the title gets filled in with its correct token value, so I'm wondering if it would be possible to open and save all nodeprofiles in a programatically way (with node_save()?) and get all titles updated.

Hans

najibx’s picture

As oppose to my comment in #2, I am now using nodeprofile :-)
Can I have the sample CSV file for this patch ? What the fields header ..

How about new CCK field? how can it modify the patch according to my new CCK or my CCK field naming?

modctek’s picture

tagging this so I don't lose track of this...I need this very exact thing to port users and their profile data to nodeprofile

robert castelo’s picture

Status: Needs work » Fixed

User Import 5.x-2.x-dev supports nodeprofile import, and has an API designed to enable integration with other modules.

ntripcevich’s picture

I wonder how hard it would be to add support for importing CCK fields for the Content Profile module to the D6-dev version of User Import?

According to this post Content Profile reads NodeProfile settings directly so one possible work-around might be to import the users into a D5 site with NodeProfile then upgrade the site to a D6 site for use with Content Profile. Any suggestions are welcome. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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