You are here

function entity_metadata_user_access in Entity API 7

Access callback for the user entity.

1 string reference to 'entity_metadata_user_access'
_entity_info_add_metadata in ./entity.module
Adds metadata and callbacks for core entities to the entity info.

File

modules/callbacks.inc, line 721
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  $account = isset($account) ? $account : $GLOBALS['user'];

  // Grant access to the users own user account and to the anonymous one.
  if (isset($entity->uid) && $op != 'delete' && ($entity->uid == $account->uid && $entity->uid || !$entity->uid && $op == 'view')) {
    return TRUE;
  }
  if (user_access('administer users', $account) || user_access('access user profiles', $account) && $op == 'view' && (empty($entity) || !empty($entity->status))) {
    return TRUE;
  }
  return FALSE;
}