[drupal-devel] Working around node_access in node/add

Moshe Weitzman weitzman at tejasa.com
Fri Feb 11 02:30:05 UTC 2005

Mark wrote:
> Hello drupal-devel,
> Lately, I've been working on the Node Relativity module, and I've come 
> up against some issues that I'm having trouble overcoming. 

This module sounds real interesting. I hope to check it out soon.

In short, there is no way today limit node creation permission as you 
wish. The node_access API was designed to limit/grant permission on 
existing nodes, not on unborn nodes.

I think your only hope is to hack the user's permissions from within 
hook_init() or something like that. you would want to strip the 'create x' 
permission unless the user is creating from within your module.

You should be sure that noone has called user_access() before you do in 
hook_init() because otherwise $perm is cached there and you can't affect that.


More information about the drupal-devel mailing list