Guest User

Untitled

a guest
Mar 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. function _get_user_account_id() {
  2. global $user;
  3. return db_query("SELECT `field_account_target_id` FROM {field_data_field_account} where `entity_id`=:user_id and `bundle` = 'user'", array('user_id' => $user->uid))->fetchField();
  4. }
  5.  
  6. function custom_node_access($node, $op, $account) {
  7. $account_id = _get_user_account_id();
  8. if ($op == 'view' || $op == 'update') {
  9. if ($node->field_account['und'][0]['target_id'] != $account_id) {
  10. return NODE_ACCESS_DENY;
  11. }
  12. }
  13. return NODE_ACCESS_ALLOW;
  14. }
Add Comment
Please, Sign In to add comment