Magento redirect after login

magento, php, redirect

Solution

This is managed from the Magento Admin area. Log in and navigate to:

System > Configuration > Customer Configuration > Login Options

And select `No` for:

 Redirect Customer to Account Dashboard after Logging in

Problem

I have a product page, in which users can login, like the website's facebook page and receive a discount for doing so. I have everything working quite smoothly, except the mini-login.phtml file keeps redirecting the user to the account page. Ideally, after login in, the user gets redirected to the page he/she was on. So that they can instantly click the 'facebook like' button after login in. I've tried adding this code to the login form, didn't do anything. ``` <form action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>" method="post"> ``` Is there a shortcode that'll allow me to redirect users to the same page they were on while loggin in?

Original source