Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 10:21
Show Gist options
  • Save martsie/25a02bac386535f07b645071d1e942ff to your computer and use it in GitHub Desktop.
Save martsie/25a02bac386535f07b645071d1e942ff to your computer and use it in GitHub Desktop.
Example of denying access to a Drupal 7 node
<?php
/**
* Implements hook_node_access().
*
* Runs every time a user tries to view a node on the website.
*/
function my_custom_module_node_access($node, $op, $account) {
if ($node->type == 'page' && $op == 'view' && !user_access('my custom permission')) {
return NODE_ACCESS_DENY;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment