I want to add a link to the site nav, such that any logged-in user can click through from the regular menu to see their orders.
I was hoping that this would work:
<?php
/**
* implement hook_menu()
*/
function mymodule_menu($may_cache) {
if ( !$may_cache ) {
global $user ;
if ( $user->uid ) {
$items[] = array(
'path' => 'user/'. $user->uid .'/orders',
'title' => t('My Orders'),
'description' => t('View your order history.'),
'callback' => 'uc_order_history',
'callback arguments' => array(arg(1)),
'access' => true,
'type' => MENU_NORMAL_ITEM,
);
}
}
return $items ;
}
?>However, I find that generating the menu entry this way doesn't make it available for inclusion in the menus at ?q=admin/build/menu, which I was hoping to do.
I'd appreciate input on the most correct way to do this.
In the meantime, here's what I did:
<?php
/**
* provide a path which redirects logged-in users to the actual page,
* and non-logged in users there via the login form
*/
function mymodule_my_orders() {
global $user ;
if ( $user->uid ) {
drupal_goto( 'user/' . $user->uid . '/orders' ) ;
} else {
drupal_goto( 'user/login', 'destination=my-orders' ) ;
}
}
/**
* implement hook_menu()
*/
function mymodule_menu($may_cache) {
if ( !$may_cache ) {
global $user ;
if ( $user->uid ) {
$items[] = array(
'path' => 'my-orders',
'title' => t('My Orders'),
'description' => t('View your order history.'),
'callback' => 'mymodule_my_orders',
'access' => true,
'type' => MENU_NORMAL_ITEM,
);
}
}
}
?>

