0

I created a custom register-trade.phtml for trade customer signups that I am pulling into a CMS page.

The issue is if a customer enters something wrong e.g. their email is already in use it redirects to /customer/account/create/ and shows the normal register form.

This form is different, has different fields and ultimately will not sign the user up in the trade group.

Can I redirect to the trade register page and display the error rather than going to /customer/account/create/ ?

  • Where is the register-trade.phtml file posting data to, does it have it's own set of controllers, or does it post to the same place as the standard register, but with different fields in the form data? – Peter O'Callaghan Mar 5 '15 at 10:52
1

Take a look at:

app/code/core/Mage/Customer/controllers/AccountController.php

Copy that file to the local code pool and amend the _loginPostRedirect() function.

Change this line to do something else:

$session->setBeforeAuthUrl( $this->_getHelper('customer')->getLoginUrl());

Basically that line sets the redirect to the standard login page if the customer login does not work. You can change that to go back to the previous page, e.g.:

 $this->_redirectUrl($session->getBeforeAuthUrl(true))

Whether that will work given the many login routes you have I do not know, however, this should get you on the right track for what you are trying to achieve. Hope that helps!

| improve this answer | |
  • Thanks for the reply! All i have done is literally coped register.phtml and made register-trade.phtml in template. If I copy AccountController.php into local and edit it how will I make only the register-trade.phtml redirect to the previous page? – KiwisTasteGood Mar 5 '15 at 12:19

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.