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' && !empty($entity) && ($field['field_name'] == 'field_accept_review' || $field['field_name'] == 'field_decline_review')) {
// is current user == node reviewer?
return ($entity->field_reviewer == $user->uid);
}
}
Do I have to use user_load() before getting to the uid of the linked user?