0

I use Feeds so that logged users can upload data. I need to keep track of which user uploads what.

In Feeds importer 'Settings' you define the author, but in my case it should not be static but defined dynamically by the system.

How can I dynamically change that? thanks

1 Answer 1

0

You will need to make sure that users import content by creating a node. You can then map the author of that node to the author of the feed items that get created.

  1. Make sure your importer is attached to a content type. Users can then import content by creating a node of that type. If you use the standalone import form, you cannot track which user uploaded what. Attach importer to a content type
  2. Map "Feed node: User ID (parent:uid)" to "User ID (uid)". This will make sure that the author of all nodes that get created will be the same as the author that is set on the feed node. Map "parent:uid" to "uid" If you are using the CSV parser, manually enter parent:uid instead as source. Map "parent:uid" to "uid" for CSV parser
2
  • for CSV it did not work, I switched to this snippet: function mymodule_feeds_presave(FeedsSource $source, $entity, $item) { global $user; $entity->uid = $user->uid; } Commented Apr 27, 2016 at 12:47
  • That works as long as the content is imported using the UI only and periodic import is turned off. If content is imported via cron, then the current user is anonymous and the author of the imported content will be user 0.
    – MegaChriz
    Commented May 4, 2016 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.