You are here

function entityreference_autocomplete_access_callback in Entity reference 8

Same name and namespace in other branches
  1. 7 entityreference.module \entityreference_autocomplete_access_callback()

Menu Access callback for the autocomplete widget.

Parameters

$type: The widget type (i.e. 'single' or 'tags').

$field_name: The name of the entity-reference field.

$entity_type: The entity type.

$bundle_name: The bundle name.

Return value

True if user can access this menu item.

1 string reference to 'entityreference_autocomplete_access_callback'
entityreference_menu in ./entityreference.module
Implements hook_menu().

File

./entityreference.module, line 365
Provides a field that can reference other entities.

Code

function entityreference_autocomplete_access_callback($type, $field_name, $entity_type, $bundle_name) {
  if (!($field = field_info_field($field_name))) {
    return;
  }
  if (!($instance = field_info_instance($entity_type, $field_name, $bundle_name))) {
    return;
  }
  if ($field['type'] != 'entityreference' || !field_access('edit', $field, $entity_type)) {
    return;
  }
  return TRUE;
}