[development] modify permissions using hook_menu_alter()
Earnie Boyd
earnie at users.sourceforge.net
Tue Apr 28 19:35:19 UTC 2009
Quoting Ryan Courtnage <subscribe at courtnage.ca>:
> On Tue, Apr 28, 2009 at 8:21 AM, Lluís <enboig at gmail.com> wrote:
>> I am developing a module which will allow users to post certain
>> content-types after 30 days of being registered.
>> I think this is achieved using hook_menu_alter(); but my code freezes
>> drupal with a white screen.
>>
>> Whats is missing in my code?
>>
>> function wu_menu_alter(&$menu) {
>> foreach (node_get_types('types', NULL, TRUE) as $type) {
>> $type_url_str = str_replace('_', '-', $type->type);
>> $menu['node/add/'.$type_url_str]['access callback'] = 'wu_role_access';
>> $menu['node/add/'.$type_url_str]['access arguments'] =
>> array('create', $type->type);
>> }
>> }
>>
You actually want to put this code in wu_menu() instead. Sorry, I
missed the first post.
>> function wu_role_access($a='',$b='',$c='',$d='',$e='') {
>> // echo "**************"; //if uncommented this is displayed
>> return true; //when it works I will implement the rest of the function
>> }
>
> FYI - I tried your code in my own module, works fine here. Did you
> clear your menu cache after making changes in hook_menu_alter()?
>
We don't want to be building the menu cache dynamically. It is an
expensive operation.
--
Earnie
-- http://r-feed.com/ -- http://for-my-kids.com/
-- http://www.4offer.biz/ -- http://give-me-an-offer.com/
More information about the development
mailing list