I am making API call to import data into Drupal. The API provides 2 filters by which I can get the data. Now I want to apply additional filter on the returned data and only save data which validate the third filter. E.g. The API - http://example.com/users?country=US&state=NY Requirement - I want to import users data into Drupal only if users age is above 18 (And from US-NYC).

Now the API do not have age filter, but it provides age in the response. How can I write a code to ask feed importer to skip import if age is below 18.

Hope I am clear asking this question.


You can do this using hook_feeds_presave to check the data prior to it being saved.

function mymodule_feeds_presave(FeedsSource $source, $entity, $item) {

  // check that this is fired only for the importer being used

    // check that the age is over 18
    if($item['age'] < '18'){
      $entity->feeds_item->skip = TRUE;
      drupal_set_message(t("Skipping user who's age is below 18", 'warning');

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.