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

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()
{

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

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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