Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 10:19
Show Gist options
  • Save martsie/25354da906cb828e6f74b0dc190d44c0 to your computer and use it in GitHub Desktop.
Save martsie/25354da906cb828e6f74b0dc190d44c0 to your computer and use it in GitHub Desktop.
Example of denying a page load based on Drupal 7 permissions
<?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