in my scenario I am using Drupal 7 with the ubercart modules. I like to add a link in my main menu that is only visible if you are an authenticated user.
For testing purposes I am using the bartik theme.
It is the same function like user/login, which is only visible if you are an anonymus user.
I found some hints and even examples in the drupal api - like
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_alter/7
The following implements hook_menu_alter to remove access to the "forum" tab for the anonymous user:
/**
* Implements hook_menu_alter.
* Check access for forum menu item.
*/
function MYMODULE_menu_alter(&$items) {
$items['forum']['access callback'] = '_accesscheck';
}
/**
* Callback to disallow access for the anonymous user.
*/
function _accesscheck(){
global $user;
return $user->uid;
}
Even after many attempts, I can't catch a value for $items, I was using main_menu.
I like to use the function in the theme template. How can I find the variables that I need to alter one item of my menu - I called it > cart <.
I even tried to print_r($items), but nothing was found.
How can I retrieve $items for the main menue