Role based menu redirect Setup:

I have a main module (called public) and several sub-modules that extend the support offered by the public module.
A sub-module (let's call it sub) functions can be accesed only by users with the role that that sub-module creates (guess what, called sub).

Some of the pages defined in public_menu() are extended by the pages defined by sub_menu().

For example, if the public module declares:

$pages["public/asl/info"] = array('page callback'=&gt;'public_asl_info', ...);


the sub module declares:

$pages["sub/asl/info"] = array('page callback'=&gt;'sub_asl_info', ...);


also, consider that sub_asl_info() extend public_asl_info() like this:

function sub_asl_info( $id)
{
    $public_page = public_asl_info( $id);
    $dip_page = sub_asl_dip_info( $id);

    $page = $public_page.$dip_page;

    return $page;
}


there are more complex cases, but this is enough to explain the setup :)

How i solved it (wrongly) so far:

function sub_menu_alter( &amp;$item)
{
    if( !has_role( 'sub'))
        return;

    $item['public/asl/info']        = $item['sub/asl/info'];
    $item["public/operatori/info"] = $item["sub/operatori/info"];
    $item["public/ospiti/info"]     = $item["sub/schedario"];
    $item["public/query"]           = $item["sub/query"];
    $item["public/tassonomia"]  = $item["sub/tassonomia"];
    $item["public/comunicazioni"]   = $item["sub/comunicazioni"];
}


The redirects are hard saved inside the menu_router table, so with more than one user logged it doesn't work.
I came to this solution based on how i solved the same problem but for blocks, however, using _block_view_alter() doesn't hit the same wall.

How do i solve this (programmatically)?

Possibly without using yet-another-module, unless really neccessary.
The final solution was much easier than i could possibly hope for.

I ended defining my own hooks and allow the sub-modules to implements the changes using said hook,s after checking the role of the user.
Using the example above, it became:

function sub_asl_info_alter( $page, $id)
{
  if( has_role('sub'))
    $page-&gt;content .= sub_asl_dip_info( $id);
 }