1

I am creating a small menu, where I want to give access to a menu item when your are an authenticated user.

So I gave permission to authenticated users to create nodes of the type 'donation', but how would I formulate that in the menu acces arguments ?

$items['donate/%'] = array(
    'title' => 'Donate',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('get_donate_form'),
    'access arguments' => array('create donation'),
    'type' => MENU_CALLBACK,
);

2 Answers 2

2

you can use user_is_logged_in() if you want only to check if the user is loged in or you can use a custom function like

$items['donate/%'] = array(
    'title' => 'Donate',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('get_donate_form'),
    'access arguments' => 'my_custom_permission',
    'type' => MENU_CALLBACK,
);

function my_custom_permission()
{

}
2
  • altough this gives me Warning: Invalid argument supplied for foreach() in menu_unserialize()
    – Nealv
    Mar 8, 2012 at 15:26
  • offcourse: it's access callback, not arguments :)
    – Nealv
    Mar 8, 2012 at 15:28
2

Don't use access arguments. Use user_is_logged_in() as access callback.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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