I'm trying to move over a WP site and I want to map fields like First Name and Last Name into custom fields I've added to users. I would also like to set the default role to something other than Authenticated.

In the wordpress_author.inc I added mappings for this:

  $this->addFieldMapping('field_user_name', 'author_first_name');
  $this->addFieldMapping('field_user_title', 'author_last_name');

and updated the role default mapping to:

  $this->addFieldMapping('roles')
     ->defaultValue(9);

How would I go about doing this?

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

It appears you've already gone about doing this;). I'm not sure what the question is, but the supported means for extending the WordPress migration classes is at http://drupal.org/node/1593478.

jnettik’s picture

Title: Custom User Fields » User notices on import.

I guess the problem I'm having is that the only thing that imports are the posts. Tags, comments and authors don't import. I originally thought this was because of the changes I made but I've reverted them and still no luck. I get a log full of these notices instead:

Undefined index: 218 File /modules/user/user.module, line 3563(file: /modules/user/user.module, line 3563)
Trying to get property of non-object File /site/modules/user/user.module, line 3563(file: /site/modules/user/user.module, line 3563)
Undefined index: 218 File /modules/user/user.module, line 3564(file: /Users/jnettik/Sites/botanic_gardens/website/site/modules/user/user.module, line 3564)
Trying to get property of non-object File /modules/user/user.module, line 3564(file: /modules/user/user.module, line 3564)
Undefined index: 218 File /modules/user/user.module, line 3565(file: /modules/user/user.module, line 3565)
Trying to get property of non-object File /modules/user/user.module, line 3565(file: /modules/user/user.module, line 3565)
The specified file /wp-content/uploads/2012/12/Aesculus-carnea-DSC00115.jpg could not be copied to public://wp-content/uploads/2012/12/Aesculus-carnea-DSC00115.jpg.

Sorry my original post wasn't more clear on this. As I said I thought the issue was that I was going about mapping the custom fields wrong. But I dont' think that's the issue now. Updating the title to reflect my problems more.

mikeryan’s picture

Be sure the change the issue status back to "active" when responding to questions - otherwise your responses may be missed.

When you exported your WordPress content, did you export all or did you filter it? If you do any filtering at all, then WordPress will not export anything but the specified pages and blog posts - it will not export the tags, users, attachments... Try doing a full export if you didn't already.

jnettik’s picture

Title: User notices on import. » Search API Solr breaks rollbacks, which in turn breaks future imports.
Version: 7.x-2.2 » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Closed (works as designed)

Ok so after spending all day yesterday digging into this I think I finally found the problem. It seems Search API, specifically Solr search, doesn't allow for rollbacks. In my case, my first import had worked but I needed to do some tweaking for custom user fields. When I tried to roll back I got this error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=276&op=do StatusText: Service unavailable (with message) ResponseText: Apache_Solr_HttpTransportException: '404' Status: Not Found in Apache_Solr_Service->_sendRawPost() (line 364 of /Users/jnettik/Sites/botanic_gardens/website/site/sites/all/libraries/SolrPhpClient/Apache/Solr/Service.php).

I restored the site from a backup I created with Backup and Migrate and tried again, this time with my updates which didn't work. What I think happened was that Solr prevented me from rolling back which left my initial import's info in the db. Backup and Migrate didn't overwrite that info which broke my future imports. After I disabled all things Search API related, I was able to roll back my import properly and importing has since worked.

I'm updating the title again to be more accurate. I'm also just marking this as works as designed. Sorry for the run around on this issue.