Filling an Entity Reference programatically I am creating a node programatically and one of the fields in the node is an entity reference field referencing a user.

I am using the guide from https://www.drupal.org/node/1388922 and the general consensus i gather is that I need to do something like;

$node-&gt;field_customer_nid[$node-&gt;language][] = array(
'target_id' =&gt; $form_state['values']['entity id'],
'target_type' =&gt; 'node',


);

My question is where do i pass the values for the target entity(basically the uid)in that array. Is it the target_id or the entity_id because my attempts with either of those is not working.
You have to specify the entity id and the entity type. The example is referencing a node but you want to reference a user.

Try this:

$node-&gt;field_customer_nid[$node-&gt;language][] = array(
  'target_id' =&gt; $entity_id,
);


$entity_id should hold the referenced entity id.