Can I use entityreference module with my custom entity to display it? I've attached a new entityreference field to users that referenced my custom entity type, say it's called my_entity. When I dpm() the user or view the tokens, I can see my custom entity properties (id, name, etc) but when I view the user I do not see the field label or the entity label. 

I threw a dpm($items) into hook_field_formatter_view() inside entityreference.module and 
discovered that there are 0 items available to be displayed, but they are available in many other places! (as described above)

In hook_entity_info():

&lt;?php
return array('my_entity' =&gt; array(
  'label' =&gt; t('My Entity'),
  'controller class' =&gt; 'MyEntityController',
  'base table' =&gt; 'my_entity',
  'uri callback' =&gt; 'my_entity_uri',
  'load hook' =&gt; 'my_entity_load',
  'fieldable' =&gt; FALSE,
  'label callback' =&gt; 'my_entity_label',
  'entity keys' =&gt; array(
    'id' =&gt; 'id',
    'label' =&gt; 'name',
  ),
);
?&gt;


I tried just setting the entity keys['label'] to the schema field, which is supposed to be adequate to set the label, but I also tried 'label callback' and even setting up the bundle info, which is not necessary for my entity.

I've also tried adding the property into hook_entity_property_info() in the hope that it would be "made aware" to other modules, but no luck:

&lt;?php
return array('my_entity' =&gt; array(
  'properties' =&gt; array(
    'name' =&gt; array(
      'label' =&gt; 'Name',
      'type' =&gt; 'text',
      'schema field' =&gt; 'name',
    ),
  ),
);
?&gt;


Any ideas?
I figured this one out. Entityreference runs entity_access() before returning $items:

$items[$id][$delta]['access'] = entity_access('view', $field['settings']['target_type'], $target_entities[$item['target_id']]);


To get this working, you need to set the 'access callback' property in hook_entity_info(), which is an extended property that is checked by entity.module, not by core's entity functionality. So, for example:

&lt;?php
return array('my_entity' =&gt; array(
  'label' =&gt; t('My Entity'),
  'controller class' =&gt; 'MyEntityController',
  'base table' =&gt; 'my_entity',
  'uri callback' =&gt; 'my_entity_uri',
  'load hook' =&gt; 'my_entity_load',
  'fieldable' =&gt; FALSE,
  'label callback' =&gt; 'my_entity_label',
  'access callback' =&gt; 'my_access_check',
  'entity keys' =&gt; array(
    'id' =&gt; 'id',
    'label' =&gt; 'name',
  ),
);

function my_access_check($op, $entity, $account, $entity_type) {
  // ...do something
  return TRUE;
}
?&gt;