[development] modify permissions using hook_menu_alter()

Ryan Courtnage subscribe at courtnage.ca
Tue Apr 28 16:16:26 UTC 2009


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);
>  }
> }
>
> 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()?


More information about the development mailing list