hook_civicrm_permission
Summary
This hook is called to allow custom permissions to be defined.
Notes
Available starting in 4.3, with permission descriptions supported starting in 4.6.
Before 4.7.21, extension permissions did not work properly in Joomla (see CRM-12059). CiviCRM would recognize the permission but not give site administrators any way to grant it to users.
Definition
hook_civicrm_permission(&$permissions)
Parameters
-
$permissions: reference to an associative array of custom permissions that are implemented by extensions, modules and other custom code. This will be an empty array unless another implementation of hook_civicrm_permission adds items to it. Items may be added in one of two formats.
-
Simple associative array in the format "permission string => label". Compatible with CiviCRM 4.3+.
$prefix = ts('CiviCRM Grant Program:') . ' '; $permissions['edit grant programs'] = $prefix . ts('edit grant programs'); $permissions['delete in Grant Program'] = $prefix . ts('delete grant program');
-
A multidimensional array in the format "permission string => array(label, description)". Compatible with CiviCRM 4.6+. The first array item is the label for the permission. If a second array item is present, it will appear as a description beneath the permission.
$prefix = ts('CiviCRM Grant Program:') . ' '; $permissions['edit grant programs'] = [ $prefix . ts('edit grant programs'), // label ts('Create or edit grant programs and their criteria'), // description ]; $permissions['delete in Grant Program'] = [ $prefix . ts('delete grant program'), // if no description, just give an array with the label ];
-