[development] Overriding function declared in another module

Jamie Holly hovercrafter at earthlink.net
Tue Jan 18 12:29:30 UTC 2011


Create your own module with hook_form_alter and just reset the 
$form['menu']['#access'] to whatever you want. The trick is to set the 
weight of your module higher than the weight of the menu module so that 
the hook runs after menu's hook_form_alter. You do this in the system 
table by altering the weight column.


Jamie Holly
http://www.intoxination.net
http://www.hollyit.net


On 1/18/2011 7:22 AM, Leonard den Ottolander.nl wrote:
> Hi,
>
> I'm trying to modify the delegate_menu_admin module in such a way that
> the node/add/page form will show the Menu Settings for users with
> "administer some menus" permissions. In it's current form the module
> will allow users with this permission to add pages via node/add/page and
> subsequently link them to menu items via admin/build/menu without having
> full "administer menu" access. However, this two step approach is not
> very convenient.
>
> The problem I face is the fact that menu_alter_form() declared in
> menu.module (Drupal 6.2) unconditionally overwrites
> $form['menu']['#access'] with "user_access('administer menu')" where I
> want it to also honour user_access('administer some menus'). I also want
> to limit the presented menus in "Parent item" to the ones that the user
> has access to but that's just a matter of filtering out the forbidden
> menus.
>
> I would like to avoid having to hack the menu module itself, so I am
> looking for a way to unhook and redefine menu_form_alter() in
> delegate_menu_admin. I don't want the module to have to rely on things
> like PECL modules (override_function() from APD is way too intrusive).
> Depending on other Drupal modules is an option but I'd rather avoid that
> too.
>
> So the question is, how do I override menu_form_alter() from another
> module?
>
> Regards,
> Leonard.
>


More information about the development mailing list