hook_perm

developer/hooks/core.php, line 1474

Versions
4.6 – 7
hook_perm()

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 restrict access to actions the module performs.

The permissions in the array must not be wrapped with the function t(), since this could lead to privilege escalation if someone "translated" one permission string into a higher privelege string. The string extractor takes care of extracting permission names defined in the perm hook for translation.

Permissions are checked using user_access().

For a detailed usage example, see page_example.module.

Return value

An array of permissions strings.

Related topics

Code

<?php
function hook_perm() {
  return array('administer my module');
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.