3

So, I want to set a new function as access callbacks for URLs specified by registration module.

Specifically I want only users that have the update rights on the node to be able to manage registrations for the node.

I implemented hook_menu_alter in this manner:

function enge_events_menu_alter($items){
  $items['node/%entity_object/registrations']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/list']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/list']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/settings']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/settings']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/broadcast']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/broadcast']['access arguments'] = array(1);  
}

but for some reason the function never fires.

If I instead redeclare the module's hook_menu and change the access callback functions there, it works and it get's written in the database after a cache clear.

Is it possible to alter access callbacks in hook_menu_alter?

closed as too localized by kiamlaluno Nov 9 '12 at 1:24

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

7
function enge_events_menu_alter(&$items){
  $items['node/%entity_object/registrations']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/list']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/list']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/settings']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/settings']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/broadcast']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/broadcast']['access arguments'] = array(1);  
}

$items should be reference variable... For more information hook_menu_alter

  • 1
    checkmark in 5 minutes. – magtak Nov 8 '12 at 11:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.