file_usage_add issue for compound field I have created a custom compound field which contains a managed_file element in the field widget form.

The issue I am having is not with saving the file, but with adding the file usage information.

I picked hook_field_presave based on some research, but this is not working for new content or translating the node.

function MODULE_field_presave($entity_type, $entity, $field, $instance, $langcode, &amp;$items) {
  switch($field['type']) {
    case 'FIELD_TYPE':
      foreach ($items as $delta =&gt; &amp;$item) {

        // save file permenantly
        if ($item['IMAGE']) {
          $file = file_load($item['IMAGE']);
          $file-&gt;status = 1;
          file_save($file);
          file_usage_add($file, 'MODULE', 'FIELD_TYPE', $entity-&gt;nid);
        }
      }
      break;
  }
}


The issue here is that when I save a newly created node, at this point, $entity-&gt;nid has not been defined. This number is required by file_usage_add.

Is there another hook that I can use to do what I'm trying to do?
You could add the file usage by implementing hook_node_insert which gives you all node fields besides what you are looking for nid and the fid using file_load in that case you could add file usage