You are here

function profile2_field_access in Profile 2 7.2

Same name and namespace in other branches
  1. 7 profile2.module \profile2_field_access()

Implements hook_field_access().

File

./profile2.module, line 1401
Support for configurable user profiles.

Code

function profile2_field_access($op, $field, $entity_type, $profile = NULL, $account = NULL) {
  if ($entity_type == 'profile2' && $op == 'view' && isset($profile)) {

    // Check if the profile type is accessible (e.g. applicable to the role).
    if (!profile2_role_access($profile)) {
      return FALSE;
    }

    // Deny view access, if someone else views a private field.
    if (!empty($field['settings']['profile2_private']) && !user_access('administer profiles', $account)) {
      $account = isset($account) ? $account : $GLOBALS['user'];
      if ($account->uid != $profile->uid) {
        return FALSE;
      }
    }
  }
}