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
  • Prepopulate Group Audience
  • Overriding Prepopulate: Do Not Use hook_form_FORM_ID_alter
  • Atrium Casetracker: Change Which Case Statuses are "Closed"
  • Casetracker with Subtasks

Monthly archive

  • April 2010 (3)
  • March 2010 (6)
  • February 2010 (2)
  • November 2009 (7)
  • October 2009 (1)
  • September 2009 (5)
  • August 2009 (1)
  • July 2009 (1)

Feeds

Syndicate contentHeadlines

casetracker cck drupal FL3 freelinking module node-form og openatrium permissions plugin spaces
<all>

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