How to Create a Custom Permission Using Drupal 7


show more Creating a custom permission provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development show less
please wait ...

Creating a custom permission

Similar to help, permissions can be created with a hook. In particular, Drupal 7 uses hook_permission which applies permissions defined in a module so they can be used from the user permissions page along with granting or restricting who can execute actions. Hook permission returns an array in a standardized format. Looking at the API documentation I can see that hook permissions takes no parameters. So the only thing I need to do is generate the array structure. Though hook_permissions array consists of a key that contains the name of the permission followed by a nested array definition that contains at the minimum two key value pairs.

A title and description each passed through the t function. There are additional options, but they are used internally and rarely. Open the IDE and navigate to the windfarms.module, start with an appropriate doc block for the new hook which implements hook permission. Create a new function named windfarms permission. Hook permission takes no p...

Creating a custom permission
Video duration: 3m 28s 2h 56m Advanced

Viewers:

Creating a custom permission provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development

Subjects:
Developer Web
Software:
Drupal
Author:
please wait ...