Unable to override default translation publishing status using entity_translation module We are using the entity_translation module in a large site, and we have 57 defined languages. We have some custom date fields in each locale, and we are using some custom code to only publish the locale when the current date is within the specified date range. However, one problem we are running into is that when an entity (node, taxonomy term) is created, the Published status for the default language (en-us in our case, defined at admin/config/regional/entity_translation) is automatically set to Published, which we don't want, so I need to override that value and set it to 0.

After delving into the module code, I found the hook_entity_translation_insert hook, which is called from EntityTranslationDefaultHandler:saveTranslations():

  foreach ($translations-&gt;hook as $langcode =&gt; $info) {
    $translation = isset($translations-&gt;data[$langcode]) ? $translations-&gt;data[$langcode] : $langcode;
    $data = isset($info['data']) ? $info['data'] : NULL;
    module_invoke_all('entity_translation_' . $info['hook'], $this-&gt;entityType, $this-&gt;entity, $translation, $data);
    // Provide Rules events integration if available.
    if (module_exists('rules')) {
      // Pass the entity as a wrapped one since rules can't do it for us
      // when using the variable type 'entity'.
      rules_invoke_event('entity_translation_' . $info['hook'], $this-&gt;entityType, entity_metadata_wrapper($this-&gt;entityType, $this-&gt;entity), $translation, $data);
    }
  }


where $op = 'insert'. I tried implementing my hook like so:

function mymodule_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  // Set the publishing status for en-us to 0.
  if ($translation['language'] == 'en-us') {
    $translation['status'] = 0;
  }
}


but that doesn't change the status that gets passed on. If I try passing $translation in by reference:

function fluke_staging_entity_translation_insert($entity_type, $entity, &amp;$translation, $values = array())


krumo gets into a huge recursive loop, and my computer maxes out the CPU.I can return a value like so:

function mymodule_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  // Set the publishing status for en-us to 0.
  if ($translation['language'] == 'en-us') {
    $translation['status'] = 0;
    return ['translation' =&gt; $translation];
  }
}


but that's worthless, too, because the hook invocation doesn't do anything with it:

module_invoke_all('entity_translation_' . $info['hook'], $this-&gt;entityType, $this-&gt;entity, $translation, $data);


as compared to 

$new_data = module_invoke_all('entity_translation_' . $info['hook'], $this-&gt;entityType, $this-&gt;entity, $translation, $data);


or something like that.

So my question is, how can I override the translation status in this hook, since it doesn't seem that it's a) passable by reference, or 2) it accepts any data from the hook_entity_translation_insert implementation?
I ended up posting this to the module issue queue and got this suggested code:

function MODULE_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  // Set the publishing status for en-us to 0.
  if ($translation['language'] == 'en-us') {
    $translation['status'] = 0;
    $handler = entity_translation_get_handler($entity_type, $entity);
    $handler-&gt;setTranslation($translation);
    // Important: Avoid infinite loops by firing the insert hook again and again.
    $handler-&gt;getTranslations()-&gt;hook = array();
    $handler-&gt;saveTranslations();
  }
}


which was pretty close to what I had come up with on my own:

function mymodule_entity_insert($entity, $type) {
  // We don't want to do this for field collections. 
   if (in_array($type, array('node', 'taxonomy_term'))) {
    // Attempt to unpublish the en-us translation that is set to published by default.
    $handler = entity_translation_get_handler($type, $entity);
    $translations = $handler-&gt;getTranslations();
    $enus_translation = $translations-&gt;data['en-us'];
    // Set the status = 0.
    $enus_translation['status'] = 0;
    $handler-&gt;setTranslation($enus_translation);
    // Save the translation.
    $handler-&gt;saveTranslations();
  }
}


And since it's not part of the saveTranslations() hook firing logic, no infinite loops should occur.