[development] node_access for not the global user?
Gordon Heydon
gordon at heydon.com.au
Mon Mar 5 23:23:30 UTC 2007
Hi,
There is 1 method of doing this (I believe) and from what I have seen in
some packages, is that you switch users to the user you want to check
and then switch back.
global $user;
$save = $user;
$user = user_load(array('uid' => 1234));
... check access to node ...
$user = $save;
It is a pain that you can't just specify a uid to check access.
Gordon.
Alan Dixon wrote:
> I'm looking for a way to determine if an arbitrary user (i.e, not the
> global or current user) has access to a node. The node_access()
> function in the node.module looks like what I want, except that it
> only applies to the current user. I only actually care if the user can
> view the node.
>
> Any ideas?
>
> I'd thought of redefining the $_GLOBAL['user'] temporarily and then
> running node_access, but I think that might be dangerous (side
> effects?). I could also just copy that node_access function and change
> the references to the global user, but I'm hoping someone's already
> thought through a more elegant solution.
>
More information about the development
mailing list