8.5.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.0.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.1.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.2.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.3.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.4.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
8.6.x entity.api.php hook_entity_load(array $entities, $entity_type_id)
7.x system.api.php hook_entity_load($entities, $type)

Act on entities when loaded.

This is a generic load hook called for all entity types loaded via the entity API.


$entities: The entities keyed by entity ID.

$type: The type of entities being loaded (i.e. node, user, comment).

Related topics

2 functions implement hook_entity_load()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_entity_load in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_entity_load().
rdf_entity_load in modules/rdf/rdf.module
Implements hook_entity_load().
2 invocations of hook_entity_load()
field_attach_load in modules/field/field.attach.inc
Loads fields for the current revisions of a group of entities.
node_preview in modules/node/node.pages.inc
Generates a node preview.


modules/system/system.api.php, line 302
Hooks provided by Drupal core and the System module.


function hook_entity_load($entities, $type) {
  foreach ($entities as $entity) {
    $entity->foo = mymodule_add_something($entity, $type);


Luzgan’s picture

Is this really launched when you loading user? Because I tried with user_load and entity_load, and for both it wasn't called. Maybe something else broke it, so I need to know for sure, if clean drupal call this.

rhclayto’s picture

I think you would use something like this in a custom module:

mymodule_entity_load(, 'user') {
  //do something

Then DrupalDefaultEntityController::attachLoad will call this hook when an entity is loaded.