开发者

Drupal destination parameter on the user account page not persistent?

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 b开发者_StackOverflowar. 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?


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();
  }
}


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.


I think you can do this just by themeing the menu links. I wrote solution here http://tappetyclick.com/blog/2013/04/11/maintain-destination-drupal-user-account-menu#.UWbt8hcmdIE for Drupal 6

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜