views:

142

answers:

2

If a user accesses:

user/register?destination=node/add/listing

And they then click on "Log In" or "Request New Password" tabs, it WONT keep the destination parameter in the address bar. I.e. After clicking on "Log in" and logging in, the user won't actually end up at:

node/add/listing

I thought of editing the core user module, but couldn't even find the right place to edit, and I know it's a really bad solution.

Does anyone know how I can get this right?

A: 

The links you are talking about are static links much like your navigation. They are cached etc, and so is not something you can change that easily. The behavior is perfered most of the time. You generally don't want to transfer querystrings to other links.

To do this, I think your best bet is not to do it in Drupal directly, but instead do it with JavaScript. You can set a js variable or check document.URL.

You probably could do this within Drupal, but given the specific case, it would not be worth the effort.

googletorp
A: 

I came across this when searching for the same issue (I was trying to find a core issue, but was unable to). Anyway, the solution I ended up putting in place is more involved than it should be, but does the job.

First, download and install the url_alter module. Then, in a custom module, implement hook_url_outbound_alter(). Below is the code I used, but many variants are possible.

/**
 * Implementation of hook_url_outbound_alter().
 *
 * If the url_alter module is enabled, and email verification is disabled,
 * this will pass the destination parameter to the registration and login tabs.
 */
function os_custom_url_outbound_alter(&$path, &$options, $original) {
  if (user_is_anonymous() && in_array($original, array('user', 'user/register', 'user/login')) && empty($options['query']) && !variable_get('user_email_verification', TRUE)) {
    $options['query'] = drupal_get_destination();
  }
}
jhedstrom