Created
January 25, 2017 10:17
-
-
Save martsie/6b9e2775efbc90f1afd0abf7c40a50ca to your computer and use it in GitHub Desktop.
A simple implementation of a custom permission check in hook_init in Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_init(). | |
* | |
* Runs every time a page is requested on the site. | |
*/ | |
function my_custom_module_init() { | |
if (user_access('my custom permission')) { | |
drupal_set_message(t('User has my custom permission')); | |
} | |
else { | |
drupal_set_message(t('User does not have my custom permission')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment