简体   繁体   English

hook_field_access不起作用

[英]hook_field_access does not work

Im trying to use hook_field_access to check if the user has the permission to edit certain fields. 我试图使用hook_field_access来检查用户是否有权编辑某些字段。 The problem is even with a return false, access is not denied. 问题是即使返回false,也不会拒绝访问。

    function applx_field_access($op, $field, $entity_type, $entity, $account){
    return FALSE;
}

Try this: 尝试这个:

function hook_field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) {
  if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
    return $account->hasPermission('edit field of interest');
  }
  return TRUE;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM