By patman on
Hi!
Drupal 4.3.2/XTemplate
I'm trying to make logins/registrations usable without having to enable the login block. Putting a link to ?q=/user or to ?q=/user/login works, except that after logging in you end up at ?q=/user. How can I redirect back to the home page like when the login block is enabled. I've looked through user.module, but don't quite understand how/where $edit is being set. Is there another parameter I can pass with the link to indicate where they should redirect back to?
Thanks!
Comments
the function you are looking for is ...
drupal uses drupal_goto function to redirect page. have a look through user.module searching for "drupal_goto" and see where it redirects to "user" ...
have fun.
let me rephrase
I understand how the drupal_goto function is being invoked, and I see how I could modify user.module to send them back to "node". I didn't ask the question correctly. What I'd like to do is redirect the user to the page they were on when they clicked the link to "user/login", which could be anywhere on the site. It seems I should be able to do this without hacking up user.module, but I'll be darned if I can figure out how...
Save referrer
When the 'user/login' page's handler is invoked, you can save the referrer in the user session and reuse it after the user completed the form. You can also save the referrer using a hidden form element, but this will only work correctly when caching is disabled.
That's what I was wondering...
What would be the recommended way of doing this? I'd hate to hack on user.module, as I like to stay fairly upgrade-proof. I'm still feeling my way around Drupal, but would it make sense to write a module that "wraps" user.module, and handles the referrer saving magic?
Thanks!
Session variable
My gut feeling says you want to save the referrer in a session variable. You update the variable for each GET operation, but not for POST operations. Then, you should be able to use the referrer variable after the user got logged in.
If this works, I would accept such patch for core. The reason is twofold:
Maybe open a feature request (or a bug report) for this so we don't forget about it.
opened as feature request
see this request
i modified the drupal_goto
i modified the drupal_goto function, so that it was
drupal_goto('user/'. $user->uid . '/orders');
which is a valid link, and now i get this error everwhere ;|
Call to undefined function user_access()
Does anyone have a more elegent solution for this problem?
Has anyone found a more elegent solution for this problem? It looks like the patch ended up getting scrapped, though I think it would be a very useful one for a lot of drupal site maintainers...