{ Posted 2nd July 2013 }
It is really easy to add a custom permission in Drupal 7, you only need to run one convientently titled hook: hook_permission(). Simply add this to your custom module.
/*** Implementation of hook_permission().*/function YOURMODULE_permission() { // Add a custom permission. return array( 'My great custom permission' => array( 'title' => t('Title of my great custom permission'), ), );}
This will add the permission to the permissions page (admin/people/permissions) and you can grant it to whichever roles you like. To test if a user has the permission you just need to call the user_access() function.
if (user_access('My great custom permission')) { // Do some cool stuff here.}