Hi all,

I've searched the forums -- I noticed a lot of people asking about redirect to last page visited after login, and also see that it has now been implemented in the core (nice work).

What I haven't found is how to redirect to the last page visited after registration. I'm using the logintoboggan module which allows you to set a static redirect after login -- alas it's static, not the last page visited.

Any thoughts?

ONE possible approach: I'm thinking the idea might be to edit the registration email to provide a link to the last page visited (whereupon they will be asked to login, can use their new username and password, and then will be taken to their last page due to the new redirect after login functionality). There is a session variable which contains the last page visited. So the question is how do I get that session variable into the registration email (which currently has certain preset variables you can use but not the last page visisted).

Thanks muchly,

Shiraz

Comments

jeff h’s picture

Hi,

Sorry to hijack your thread, but can you point me to the discussions where a good solution was found for redirecting a user to the last page they visited after login? And this is now in core? For 4.7.x or 5?

Thanks,
Jeff

kuahyeow’s picture

http://api.drupal.org/api/4.7/function/drupal_get_destination

For example, in e-commerce, this produces a link such as ?q=user&destination=cart/checkout.

--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

oknate’s picture

add the destination onto your login page in your link

http://www.mysite.com/mydrupalfolder/user?destination=mypath

kuahyeow’s picture

Sorry. you are confusing me. just to clear things up. what do you mean by "last page visited" in the context of an email?

--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

Shiraz Dindar’s picture

Jeff - just search the forum for "redirect login". And yes, it is implemented in the 4.7 core, so you don't really have to do anything. Actually I could be wrong -- this could be part of the logintoboggan functionality but I don't think so.

Thong -- I don't understand what you're asking by "context of an email" at all. I'm not even sure if you're addressing the question to me.

kuahyeow’s picture

sorry, i wasn't clear about replying to you before.

I just wanted to be clear about the usage of emails. Note that emails and web pages are served in different programs. Hence trying to determine the last page visited (when the user can click on the email ages later) creates lots of problems in users finding themselves in unfamiliar pages.

Anyway, I have just tested it out, using login toboggan, you can redirect just using the destination parameter, e.g.

?q=user/register&destination=cart/checkout

--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

sickhippie’s picture

While you can redirect using the destination parameter, that doesn't solve the problem of dynamic redirect. Say someone is shopping, and about to check out. They register, then login, and they're back at the home page. No problem, right? Change it to the shopping cart destination. So what if someone is trying to post in the forum? They register, then login, and they're at the.... shopping cart?

Seriously, every other CMS, ecommerce package, and forum I've ever worked with has this functionality built in. So where is it in Drupal, and how can I find and implement it?

kuahyeow’s picture

Try

http://api.drupal.org/api/4.7/function/drupal_get_destination

If you want dynamic redirection. Please go the docs and RFTM.

--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

sickhippie’s picture

That was incredibly unhelpful. Now I know that there is a function built into Drupal that can do this. Wonderful. This gives me ZERO help with implementation, and your condescending attitude is really irritating.

This is why I don't like Drupal. It is not that the software does not work, because it does. It is not the steep learning curve, because I really don't mind learning new things. It is the self-righteous ARROGANCE of the "hard-core Drupal community" that pisses me off. Nowhere else in the open source CMS world is there such a group of unhelpful people who seem to get a kick out of being arrogant bastards.

I will go elsewhere for assistance in this - perhaps to someone who doesn't just post a link and say RTFM.

Cheers!

kuahyeow’s picture

I'm sorry if you were offended, but I think you are trying to find fault where it does not exist.

I have posted more than a link, I have even posted explanations in the grand-parent post. Btw, the link should be quite simple to understand. If you want more help about this, start a new thread describing what you want to achieve in detail, as well as your background.
--
Cheers,
Thong

Tip: http://drupal.org/forum-posting
Website: http://www.edoodle.co.nz
Drupal for artists - demo at Website for artists

ljkar’s picture

I have found a hack that works in Drupal 5.x. It may work in other versions - I don't know:

Go into the users.module file and search for the user_register_submit function. You have to weed through the code in this function and find the section that deals with whatever you have your user settings set to. For example, I have mine set to administrator approval required for user registration, so I go to the section that looks like this:

} else {
// Create new user account, administrator approval required.

(code for this section)

}

So then, right before the end of this section I add a call to drupal_goto(), and pass it the node of the page that I want it to land on:

} else {
// Create new user account, administrator approval required.

(code for this section)

drupal_goto('/node/25'); <----- add this and substitute the node you want to land on
}

--hope this helps.

Soggydoughnuts’s picture

That did not work... in fact it jacked up my entire user.module file and I cant fix it.

Dont try that on 6.0

-Donuts