We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Login Redirect to where member was going

Development and Programming

maxbato's avatar
maxbato
42 posts
15 years ago
maxbato's avatar maxbato

Workflow:

  1. User, adds stuff to cart while not logged in
  2. Clicks checkout (checkout template is set to redirect to custom login page for guests)
  3. Login page should redirect back to checkout page upon success.

Is this the best way to achieve this?

{exp:member:login_form return="<?php echo 
"http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}" ?>"}

There must be a better way, no?

       
ender's avatar
ender
1,644 posts
15 years ago
ender's avatar ender

instead of redirecting to your login template you could use an embedded login form on the checkout page within a {if not_logged_in} conditional and then return them to the current page.

       
maxbato's avatar
maxbato
42 posts
15 years ago
maxbato's avatar maxbato

I thought of that but then I would need to have one on all other pages of the site that require login.

Profile, etc.

Basically I was hoping for an EE variable that exists that can do the same as the PHP above.

       
Derek Jones's avatar
Derek Jones
7,561 posts
15 years ago
Derek Jones's avatar Derek Jones

You need the page previous, then, right? Not the current request, because that’s your login page. You could use flashdata for that, or even the session tracker cookie which stores the previously viewed pages in order. There’s not a global template variable to access that, though, you’ll need PHP.

       
maxbato's avatar
maxbato
42 posts
15 years ago
maxbato's avatar maxbato

No problem. I will stick with what I have.

Thanks for your help.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.