I'm trying to deny access to content for anonymous users by default and only allow access for specific nodes. So I tried to set global user privilige 'access content' for anonymous users to off and content access 'view' for a specific node to on, but still I get the message 'You are not authorized to access this page'?

Shouldn't this work, am I missing something?

Comments

mantyla’s picture

Status: Active » Closed (fixed)

No, that is not how it works. The role must have the access content on for node access to come to play at all.

What you can do, however, is revoke the anonymous view rights from all the nodes you want to hide. This is easy for the nodes that only have default permissions: you simply need to go to the Nodeaccess administration page and remove the anonymous view permission from each content type you want. Save, and you'll have revoked anonymous view from all nodes that have default permissions. The nodes that do not have default permissions are more troublesome: you need to revoke the view rights node by node, and there is no simple method to search for which nodes you need to touch by hand.

You could use sql to do a global revoke of view rights too, but that only works if you can enter your sql server to run such commands. Just in case you can, here's how:

UPDATE node_access SET grant_view = 0 WHERE realm = 'nodeaccess_rid' AND gid = 1;
UPDATE nodeaccess SET grant_view = 0 WHERE realm = 'nodeaccess_rid' AND gid = 1;

These will remove view permissions from roles with a rid (role id) of 1, which is anonymous.