hook_permission
- Versions
- 7
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 of which permission names are the keys and their corresponding values are descriptions of each permission. The permission names (keys of the array) must not be wrapped with the t() function, since the string extractor takes care of extracting permission names defined in the perm hook for translation. The permission descriptions (values of the array) should be wrapped in the t() function so they can be translated.
Related topics
Code
modules/system/system.api.php, line 864
<?php
function hook_permission() {
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
);
}
?>Login or register to post comments 