Grayside.Org

Home

Feeds Usermapper

grayside — Mon, 04/12/2010 - 13:14

If you are using Feeds to migrate site content, one of the stumbling blocks will be preserving content ownership.

This code is taken from a hypothetical feeds_usermapper module that provides the option to sync up node ownership on the basis of identical usernames. (Pulled from User Inheritance Issue on D.O)

<?php
/<strong>
*
Implementation of hook_migrate_fields_node().
*/
function
feeds_usermapper_feeds_node_processor_targets_alter(&$targets, $content_type) {
 
$targets['uid'] = array(
   
'name' => t('Node author'),
   
'description' => t('The owner of the node.'),
   
'callback' => 'feeds_usermapper_feeds_set_target',
  );
}

/</
strong>
*
Mapping callback for author.
*/
function
feeds_usermapper_feeds_set_target($node, $target, $value) {
 
// [insert optional username transformation here]
 
$user = user_load(array('name' => $value));
  if (isset(
$user->uid)) {
   
$node->uid = $user->uid;
  }
}
?>

  • drupal
  • feeds
  • migration
  • Add new comment

Similar Posts

  • CCK Fields and the Open Atrium Node Form
  • Modifying Contexts the Old-Fashioned Way
  • Firefox's Custom Keywords and Drupal
  • Optional Spaces Integration for a View
  • Automatic Nodetitles is Usually Overkill

Monthly archive

  • September 2010 (2)
  • August 2010 (2)
  • July 2010 (2)
  • June 2010 (6)
  • May 2010 (9)
more

Feeds

  • Syndicate contentHeadlines
  • Syndicate contentDrupal Planet
  • Syndicate contentAtrium Headlines

casetracker cck drupal features FL3 freelinking module og openatrium permissions spaces views
<all>

© 2009 grayside.org ♠ Glossary ♠ Powered by Drupal ♠ Floating on Archlinux