3

I currently have a login form which opens when a customer clicks a link in the header (instead of going off to /customer/login). Apart from a few field ID's, it's pretty much unchanged from customer/templates/form/login.phtml.

How do I call the current url into the form so it doesn't redirect to the account page? (I have disabled that feature in the CMS also)

I know from various tutorials this can be achieved using this as url:

$url  = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
$login_url = $block->getUrl('customer/account/login', array('referer' => base64_encode($url)));

But I'm not quite sure how to integrate that into the custom form.

Thanks

0

After looking at the action on the login page, I realised I was overthinking it. I could actually apply the same logic.

So essentially it's the same as the code posted in the question, but replacing customer/account/login with customer/account/loginPost

At the top of my modal, I used this:

$url  = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
$login_url = $block->getUrl('customer/account/loginPost', array('referer' => base64_encode($url)));

And simply used the $login_url as the action for that form.

Woo!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.