2 * Implements hook_node_access_records_alter().
4 function {{ machine_name }}_node_access_records_alter(&$grants, $node) {
5 // Our module allows editors to mark specific articles with the 'is_preview'
6 // field. If the node being saved has a TRUE value for that field, then only
7 // our grants are retained, and other grants are removed. Doing so ensures
8 // that our rules are enforced no matter what priority other grants are given.
9 if ($node->is_preview) {
10 // Our module grants are set in $grants['example'].
11 $temp = $grants['example'];
12 // Now remove all module grants but our own.
13 $grants = array('example' => $temp);