How to restrict field permissions to referenced user? I have a submit-review process where submitters choose their reviewer. The reviewers are linked By User Reference module. Submissions are public but have an Accept/Deny review button implemented with Button Field which only should be accessible by referenced user.

Workflow fields submodule seems to accomplish that behavior but unfortunately I can't get it to work with Workflow. There is an incompatibility of versions and maintenance seems not to be very active. 

So I try to build my own solution using hook_field_access() like that:

function MYMODULE_field_access($op, $field, $entity_type, $entity, $account) {
  global $user;
  if ($op == 'view' &amp;&amp; !empty($entity) &amp;&amp; ($field['field_name'] == 'field_accept_review' || $field['field_name'] == 'field_decline_review')) {
        // is current user == node reviewer?
        return ($entity-&gt;field_reviewer == $user-&gt;uid);
    }
}


Do I have to use user_load() before getting to the uid of the linked user?
I assume field_reviewer is an user reference field with only a single value allowed. If so use the following to get the referenced user's uid which is directly stored in field_reviewer array in submission:

// is current user == node reviewer?
if (!empty($entity-&gt;field_reviewer)) {
  $reviewerId = $entity-&gt;field_reviewer['uid'];
  return ($reviewerId == $user-&gt;uid);
}
return FALSE;