Created
January 25, 2017 10:19
-
-
Save martsie/25354da906cb828e6f74b0dc190d44c0 to your computer and use it in GitHub Desktop.
Example of denying a page load based on Drupal 7 permissions
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() { | |
// Return a 403 page and prevent further operations if the user does not have the right permissions. | |
if (!user_access('access content')) { | |
drupal_access_denied(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment