I have a user entity reference field that's a part of a content type and I am creating a module to use that entity reference field to get the user's id and then use the id as necessary.
The hook_node_presave($node) hook passes the $node object by reference but the entity reference field doesn't seem to be apart of the $node object.
This is how I am trying to access the entity reference field:
$customerId = $node->field_customer['und'][0]['entity']->uid;
and this is the error that comes up:
Notice: Undefined index: entity in test1_node_presave() (line 35 of /home/username/public_html/sites/all/modules/custom/test1/test1.module).
Comments
Comment #1
doors CreditAttribution: doors commentedI was using the wrong variable to access the entity. it should have been:
$customerId = $node->field_customer['und'][0]['target_id']