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

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
  • 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; } – user1249791 Apr 27 '16 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 May 4 '16 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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