You can, using code similar to the following one.
function lms_core_menu() {
$items = array();
$items['user/myresults'] = array(
'title' => 'My Results',
'type' => MENU_NORMAL_ITEM,
'menu_name' => 'navigation',
'access callback' => 'user_is_logged_in',
'page callback' => 'lms_core_myresults_page',
);
return $items;
}
function lms_core_myresults_page() {
global $user;
// Use $user for the user account information.
}
If you want to show the menu item as menu tab, and as menu link, you can use code similar to the following one.
function lms_core_menu() {
$items = array();
$items['user/myresults'] = array(
'title' => 'My Results',
'menu_name' => 'navigation',
'access callback' => 'user_is_logged_in',
'page callback' => 'lms_core_myresults_page',
);
$items['user/%user/myresults'] = array(
'title' => 'My Results',
'type' => MENU_LOCAL_TASK,
// The default access callback is user_access(), when the
// access arguments are an array containing the permission users must have
// to see the menu item.
'access arguments' => array('the permission to see this tab'),
'page callback' => 'lms_core_myresults_tab',
'page arguments' => array(1),
);
return $items;
}
function lms_core_myresults_page() {
global $user;
// Use $user for the user account information.
}
function lms_core_myresults_tab($account) {
// Use $account for the user account for which the tab is shown.
}
The difference is that the menu link will be visible only to the currently logged-in users for their own account, while the tab will be visible to every user with the right permission, for the user account %user. (This means users could see the tab for their own account, or for the accounts of other users, depending on the permission.)
Instead of the default access callback, you can use a custom one, as in the following code.
function lms_core_menu() {
$items = array();
$items['user/%user/myresults'] = array(
'title' => 'My Results',
'type' => MENU_LOCAL_TASK,
// Instead of the default access callback, the code uses a custom one.
// The argument passed to the access callback is the user object matching the
// user ID passed in the URL.
'access callback' => 'lms_core_user_access',
'access arguments' => array(1),
'page callback' => 'lms_core_myresults_tab',
'page arguments' => array(1),
);
return $items;
}
function lms_core_myresults_tab($account) {
// Use $account for the user account for which the tab is shown.
}
function lms_core_user_access($account) {
if ($account->uid == $GLOBALS['user']->uid) {
// The currently logged-in user is watching the tab for her/his own account.
return user_access('permission for the users who watch their own account');
}
else {
return user_access('permission for the users who are watching the account of another user');
}
}
In this example, the access callback checks a different permission, if the user is watching the tab for another user account, or her/his own user account.