1 field_permission_example.module field_permission_example_permission()

Implements hook_permission().

We want to let site administrators figure out who should be able to view, edit, and administer our field.

Field permission operations can only be view or edit. It is different from content types, where we also have to worry about who can create or delete content.

Related topics

File

modules/examples/field_permission_example/field_permission_example.module, line 86
Hook implementations for the Field Permission Example module.

Code

function field_permission_example_permission() {
  // Note: This would be very easy to generate programmatically,
  // but it's all typed out here for clarity.
  // The key text is the machine name of the permission.
  $perms['view own fieldnote'] = array('title' => t('View own fieldnote'));
  $perms['edit own fieldnote'] = array('title' => t('Edit own fieldnote'));
  $perms['view any fieldnote'] = array('title' => t('View any fieldnote'));
  $perms['edit any fieldnote'] = array('title' => t('Edit any fieldnote'));

  return $perms;
}