You are here

function og_ui_field_access in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og_ui/og_ui.module \og_ui_field_access()

Implements hook_field_access().

File

og_ui/og_ui.module, line 814
Organic groups UI.

Code

function og_ui_field_access($op, $field, $entity_type, $entity, $account) {
  global $user;
  if (!og_is_group_audience_field($field['field_name'])) {
    return;
  }
  if (!$user->uid) {

    // User is anonymous, and user register might try to add the group-audience
    // field.
    return;
  }
  if ($op != 'edit') {
    return;
  }
  if ($entity_type != 'user') {
    return;
  }
  list($id, $vid, $bundle_name) = entity_extract_ids($entity_type, $entity);
  $instance = field_info_instance($entity_type, $field['field_name'], $bundle_name);
  if (!empty($instance['settings']['behaviors']['og_widget']['access_override'])) {
    return;
  }
  if (!user_access('administer group', $account)) {
    return FALSE;
  }
}