[development] Blocks and page context

Jennifer Hodgdon yahgrp at poplarware.com
Fri Apr 23 22:12:51 UTC 2010

E.J. Zufelt wrote:
> I notice that menu_get_item() will tell me if the current user can access the current menu item.  Is there a simple method to test if user0 can access the current menu item?  That is, regardless who the current user is, I would like to see if there is a function to let me know if user0 can access the current page, essentially a test to see if the current page is available to anonymous users or not.

I don't think there's an easy way. The access checking for 
menu_get_item() is done in _menu_check_access(). This figures out and 
calls the access callback for the particular menu item. For the most 
general case of a menu item with a custom access callback, it would 
probably not be possible to modify the function to check a specific 
$account instead of the current global $user, without some sort of hack.


Jennifer Hodgdon * Poplar ProductivityWare
Drupal, WordPress, and custom Web programming

More information about the development mailing list