function hook_permission

cis7 system.api.php hook_permission()
cle7 system.api.php hook_permission()
elmsmedia7 system.api.php hook_permission()
icor7 system.api.php hook_permission()
meedjum_blog7 system.api.php hook_permission()
mooc7 system.api.php hook_permission()

Define user permissions.

This hook can supply permissions that the module defines, so that they can be selected on the user permissions page and used to grant or restrict access to actions the module performs.

Permissions are checked using user_access().

For a detailed usage example, see page_example.module.

Return value

An array whose keys are permission names and whose corresponding values are arrays containing the following key-value pairs:

  • title: The human-readable name of the permission, to be shown on the permission administration page. This should be wrapped in the t() function so it can be translated.
  • description: (optional) A description of what the permission does. This should be wrapped in the t() function so it can be translated.
  • restrict access: (optional) A boolean which can be set to TRUE to indicate that site administrators should restrict access to this permission to trusted users. This should be used for permissions that have inherent security risks across a variety of potential use cases (for example, the "administer filters" and "bypass node access" permissions provided by Drupal core). When set to TRUE, a standard warning message defined in user_admin_permissions() and output via theme_user_permission_description() will be associated with the permission and displayed with it on the permission administration page. Defaults to FALSE.
  • warning: (optional) A translated warning message to display for this permission on the permission administration page. This warning overrides the automatic warning generated by 'restrict access' being set to TRUE. This should rarely be used, since it is important for all permissions to have a clear, consistent security warning that is the same across the site. Use the 'description' key instead to provide any information that is specific to the permission you are defining.

See also

theme_user_permission_description()

Related topics

141 functions implement hook_permission()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

accessibility_content_permission in sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
Implements hook_permission().
accessibility_permission in sites/all/modules/ulmus/accessibility/accessibility.module
Implements hook_permission().
accessibility_reporting_permission in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/accessibility_reporting.module
Implements hook_permission().
accessibility_theming_permission in sites/all/modules/ulmus/accessibility/modules/accessibility_theming/accessibility_theming.module
Implements hook_permission().
actions_permissions_permission in sites/all/modules/ulmus/views_bulk_operations/actions_permissions.module
Implements hook_permission().

... See full list

17 invocations of hook_permission()
cis_install in profiles/cis/cis.install
Implements hook_install().
ctools_perm_ctools_access_settings in sites/all/modules/ulmus/ctools/plugins/access/perm.inc
Settings form for the 'by perm' access plugin
ctools_perm_ctools_access_summary in sites/all/modules/ulmus/ctools/plugins/access/perm.inc
Provide a summary description based upon the checked roles.
DrupalWebTestCase::checkPermissions in modules/simpletest/drupal_web_test_case.php
Check to make sure that the array of permissions are valid.
EntityReferencePrepopulateInstanceBehavior::settingsForm in sites/all/modules/ulmus/entityreference_prepopulate/plugins/behavior/EntityReferencePrepopulateInstanceBehavior.class.php
Generate a settings form for this handler.

... See full list

File

modules/system/system.api.php, line 2103
Hooks provided by Drupal core and the System module.

Code

function hook_permission() {
  return array(
    'administer my module' => array(
      'title' => t('Administer my module'),
      'description' => t('Perform administration tasks for my module.'),
    ),
  );
}