I have a module that is using hook_feeds_presave. I want to only run specific parts of this function based on the feeds importer that is running. How can I check for the ID of the feed? These are standalone feeds and don't use node forms.

3 Answers 3


Try printing $source->id ( even if $source seems empty ). This should return the machine name. It's what I always use.

  • please tell exact it works or not.
    – monymirza
    Dec 1, 2012 at 7:58
  • The "even if $source seems empty" part doesn't make sense to me, what do you mean?
    – Letharion
    Dec 1, 2012 at 13:15
  • When I print the variable $source ( using dpm() function from Devel ) in hook_feeds_presave(), I get '(Object) FeedsSource', but I cannot explore it further. I can't click on it to see what else is in there. However, by looking through the code of Feeds, I noticed that $source has a property 'id', so I tried printing that. And it works, I can see the machine name of my feed importer when I print $source->id in hook_feeds_presave()
    – Vodde
    Dec 3, 2012 at 13:16

Not tested but I think you can print_r and see yourself. function MYMODULE_feeds_presave($source, &$node){ drupal_set_message(print_r($source,1)); }

  • That didn't work - I'm getting an empty object array
    – revolt
    Oct 18, 2012 at 0:12
function MYMODULE_feeds_presave(FeedsSource $source, $entity, $item) { 
                # code...

$source->importer->id provides the ID of the feed

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.