The Devel module has a really nice Node Access block that displays a table containing all the users, roles and permissions that apply to all node content on a page. However, it displays the numeric user ID and role ID rather than the username or role name. There is a column named "explained" however, that can be used to provide a more useful explanation of what the permissions mean. This column is populated from content returned by hook_node_access_explain(). Nodeaccess doesn't implement this hook, but I think it would be great if it did. I've added the following code to our Drupal 7 site running Nodeaccess 7.x-1.4 to implement this hook. It works great for us, so I though I'd contribute it back. I think it would make a great addition to a future version of Nodeaccess, but feel free to do with it what you like
/**
* Implements hook_node_access_explain().
*/
function nodeaccess_node_access_explain($row) {
$explain = '';
if (($row->realm == 'nodeaccess_author') || ($row->realm == 'nodeaccess_rid')) {
if ($row->realm == 'nodeaccess_author') {
$account = user_load($row->gid);
$explain = 'User ' . drupal_placeholder($account->name);
} else {
$role = user_role_load($row->gid);
$explain = 'Role ' . drupal_placeholder($role->name);
}
$permissions = array();
if ($row->grant_view) {
$permissions[] = 'View';
}
if ($row->grant_update) {
$permissions[] = 'Update';
}
if ($row->grant_delete) {
$permissions[] = 'Delete';
}
if (empty($permissions)) {
$explain .= ' has no access';
} else {
$explain .= ' has ' . implode(', ', $permissions) . ' access';
}
}
return $explain;
}
Comments
Comment #1
alisonProbably won't get to implement this, but it's a neat idea, so I'll wait to close it for a little bit -- maybe someone wants to revisit it :)
(Also updated API reference link.)
Comment #2
d.fisher commentedDrupal 7 security support has ended as of 5 January 2025.
We are doing some housekeeping on the nodeaccess issue queue and moving all Drupal 7 issues to "postponed (maintainer needs more info)". See https://www.drupal.org/project/nodeaccess/issues/3516593.
If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to comment and we will change the version against this issue. If we do not hear any feedback within 2 weeks (9th October 2025) we will go ahead and close this issue as outdated.
Thank you.
Comment #3
d.fisher commentedAs per the above, as there has been no response we will now close this issue as outdated.
If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to update the version on this issue and reopen it.
Thank you.