with my custom drupal-module i'm trying to insert add a menu-item to a menu using hook_menu()
.
It should display the user-name linked to the user-profile.
(My task could be similar to Add menu item/link to Drupal menu (programatically?).)
[Edit:] I tried to solve the task with the following, but it could be, that its the wrong way to do it..
function mymodule_view_user_page()
{
global $user;
if ($user->uid != 0) {
/*$items = array(
'link_path' => drupal_get_normal_path('user'),
'link_title' => 'Account',
'menu_name' => 'main-menu',
'weight' => 8,
);*/
$items['user'] = array(
'title' => 'Page name',
'description' => t('Account'),
'menu_name' => 'main-menu',
'weight' => 8,
'access callback' => TRUE,
'page callback' => 'mymodule_view_user_page',
'access arguments' => array('view own profile'), // permission
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
}
function mymodule_view_user_page_view_user_page()
{
drupal_goto('user');
}
With the code above there is nothing showing up, but also no errors..
I probably don't want to use an page callback
since that page already exists properly but i'm unsure about not setting it.
The hook_menu()
documentation-page hook_menu is really extensive but it seems i'm not understanding it correct and beginning to loose hairs over it..
Thank you for hints! PP