diff --git a/entityreference.module b/entityreference.module
index c0c9f58..22e1c66 100644
--- a/entityreference.module
+++ b/entityreference.module
@@ -1294,6 +1294,26 @@ function entityreference_field_formatter_prepare_view($entity_type, $entities, $
   }

   if ($target_ids) {
+
+    // Allow other modules to exclude some references where access should be
+    // checked in bulk.
+    if (variable_get('entityreference_prepare_view_access_query_alter', FALSE)) {
+      $query = new EntityFieldQuery();
+      $query->addTag('entity_prepare_view_access');
+      $query->addMetaData('entity_target_type', $target_type);
+      $query->addMetaData('entity_target_ids', $target_ids);
+      $query->entityCondition('entity_type', $target_type);
+      $query->entityCondition('entity_id', $target_ids);
+      $result = $query->execute();
+
+      if (!empty($result[$target_type])) {
+        $target_ids = array_keys($result[$target_type]);
+      }
+      else {
+        $target_ids = array();
+      }
+    }
+
     $target_entities = entity_load($target_type, $target_ids);
   }
   else {
