To add an new tab with the hook_menu_local_tasks_alter() I use as example this code:
// Insert the new tab.
$data['tabs'][0]['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => array(
'title' => mb_content_createnew_title(),
'href' => 'node/add/' . $node->type,
'tab_root_href' => 'node/' . $node->nid,
'weight' => 2,
'localized_options' => array(
'attributes' => array(
'title' => t('Create new @content', array('@content' => t($node_type_name))),
)
)
)
);
To place the new tab after the View or the Edit tab are used the weight 2.
But, this weight are not used. The position of the added tab is all ways the right side of all exist tabs. This is the bug.
To fix this bug and place the added tab on the defined position I must use extra code. To see example code to make a proper tab position please take a look at the code of the More Buttons Content module.
mb_content.module See lines 318 - 329 and line 348.