Keep the destination argument in when user switch from user login to register? I have a link for users to click so that they can add a specific node type, and I use a link like below so that if the user isn't logged in, he/she can login and then be redirected to the node form, and if already is, directly goes to that form.

Now, if the user isn't registered yet, and clicks the register tab instead when coming to /user (or /user/login), the destination argument disappears, and when the user has filled out the form and is all set, he/she will be forwarded to the start page, and not the node form, that I wanted.

What would I have to do to keep this destination argument if the users registers in the process?

I tried Rules - nothing. And now I'm trying to use form/menu alter to either add the destination argument to the link, or create a completely new tab for this, and hide the other one.

Help!

Url example: example.org/user/login?destination=/node/add/help
I found for Drupal 7 there is no need to override the theme function, just adding a preprocess hook is enough.

/**
 * Add destination param to user tabs if set.
 * Implements HOOK_preprocess_menu_local_task()
 */
function THEME_preprocess_menu_local_task(&amp;$variables) {
    $link = &amp;$variables['element']['#link'];
    // check for $_GET['destination'] because drupal_get_destination() always contains at least the current page
    if ($link['tab_root'] === 'user' &amp;&amp; !empty($_GET['destination'])) {
      $link['localized_options']['query'] = drupal_get_destination();
    }
}


Replace THEME with the name of your theme or module.