Posted by Geijutsuka on February 7, 2013 at 11:12pm
I've created a simple module which sets the default view of a person's account to "Edit" (code below). It all works fine except the menu list item is not gaining a status/class of "active." I'm not sure if it has anything to do with what's going on in #1627276: Active trail system does not respect whether a menu is set as inactive or preferred using menu_set_active_menu_names().
custom module code:
function <mymodule>_menu_alter(&$items) {
// Specify the View page as just a regular tab.
// You do not need to change this block: this will always be the same as long
// as you don't want View to be the default tab.
$items['user/%user/view']['type'] = MENU_LOCAL_TASK;
$items['user/%user/view']['page callback'] = $items['user/%user']['page callback'];
$items['user/%user/view']['page arguments'] = $items['user/%user']['page arguments'];
$items['user/%user/view']['access callback'] = $items['user/%user']['access callback'];
$items['user/%user/view']['access arguments'] = $items['user/%user']['access arguments'];
// Normal tabs don't have a weight
unset($items['user/%user/view']['weight']);
// Change default action to take when hitting user/<UID> to
// the settings of the page you want to use.
// -- Custom settings start here --
$items['user/%user']['page callback'] = $items['user/%user/edit']['page callback'];
$items['user/%user']['page arguments'] = $items['user/%user/edit']['page arguments'];
$items['user/%user']['access callback'] = $items['user/%user/edit']['access callback'];
$items['user/%user']['access arguments'] = $items['user/%user/edit']['access arguments'];
$items['user/%user']['file'] = $items['user/%user/edit']['file'];
// Specify the Edit page as the default tab and remove settings
// already set above
$items['user/%user/edit']['type'] = MENU_DEFAULT_LOCAL_TASK;
$items['user/%user/edit']['weight'] = -10;
unset($items['user/%user/edit']['page callback']);
unset($items['user/%user/edit']['page arguments']);
unset($items['user/%user/edit']['access callback']);
unset($items['user/%user/edit']['access arguments']);
unset($items['user/%user/edit']['file']);
}