2
votes

I would like to redirect all customers to a custom page after successful registration in Magento 1.9.

I have tried many things. Firstly, I am successfully overriding the core customer account controller.

I have attempted to customize the following actions:

  • createPostAction
  • _successProcessRegistration
  • _welcomeCustomer

By trying to set redirect url or by setting BeforeAuthUrl

    //$successUrl = $this->_getUrl('*/*/index', array('_secure' => true));
    $successUrl = $this->_getUrl('*/*/success');
    $this->_getSession()->setBeforeAuthUrl('http://test.local/customer/account/success/');
    if ($this->_getSession()->getBeforeAuthUrl()) {
        $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
    }
    return $successUrl;

Please note at this point, $successUrl is correct when it returns here. I see there are some post Dispatch methods that I am assuming are destorying this url and always returning to customer/account/index.

I have read several posts on this topic and cannot find a definitive answer that solves this question.

I have even set hidden form element 'success_url' in attempts to follow steps presented elsewhere as solutions to this.

What is the full, correct process that one needs to follow in order to be able to show a one time registration success page?

3
you want this only during customer regisration?Amit Bera
Yes please, only during registration.activeDev
Doesnt work for me! about to try on standard 1.9 and will get back!activeDev
Wait give u total solution. This event occur immediat eafter customer successfully registerAmit Bera

3 Answers

6
votes

I know this is an old thread maybe this will help someone else out trying to accomplish the same thing. You can set the redirect URL in the register.phtml template directly without having to modify controllers or create a module. You can set success and error URLs with hidden inputs like this.

<input type="hidden" name="success_url" value="my-custom-success-url.html" />
<input type="hidden" name="error_url" value="my-custom-error-url.html" />

I used this to redirect the user back to where they entered the login/register process like this:

<?php $ref = $this->getRequest()->getParam('referer');?>
<input type="hidden" name="success_url" value="<?php echo !empty($ref)?Mage::helper('core')->urlDecode($ref):$this->getSuccessUrl(); ?>" />
1
votes

if you want to do this for customer successfully then you can do this using event observer

after customer successfully magento trigger an event customer_register_success

This call an observer which will reequestion to custtom page

  Mage::app()->getResponse()->setRedirct($Yourdreicurll);

Details:

Step1: create config.xml is app/code/community/Amit/Custommodule/etc/ - See more at: http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/#sthash.JSktrUD0.dpuf and it code

<?xml version="1.0" ?>
<config>
    <modules>
        <Amit_Custommodule>
            <version>1.0.0</version>
        </Amit_Custommodule>
    </modules>
    <global>
        <models>
            <custommodule>
                <class>Amit_Custommodule_Model</class>
            </custommodule>
        </models>
    </global>
    <frontend>
      <events>
          <customer_register_success>
        <observers>
          <notify_user>
            <class>custommodule/observer</class>
            <method>myredirection</method>
          </notify_user>
        </observers>
          </customer_register_success>     
        </events>
    </frontend>
</config>

Step2:

create module control file Module name as Amit_Custommodule.xml at app/etc/modules/

it code is

<?xml version="1.0"?>
<config>
    <modules>
        <Amit_Custommodule>
            <codePool>community</codePool>
            <active>true</active>
        </Amit_Custommodule>
    </modules>
</config>

Step3:

Create observer.php at Amit>Custommodule>Model

code is

 <?php
    class Amit_Custommodule_Model_Observer {
        public function myredirection(Varien_Event_Observer $observer) {
        $AccountController = $observer->getEvent()->getAccountController();

        $Customer = $observer->getEvent()->getCustomer();

         $response1 = Mage::app()->getResponse(); // observers have event args

            $url = 'http://www.example.com/';
            $response1->setRedirect($url);
            Mage::app()->getFrontController()->sendResponse();

        return;
      }
    }
1
votes

You are doing this in right way, this is the best way to redirect customer to custom URL.

  1. Go to customer accountcontroller find _welcomeCustomer method.
  2. Search for $successUrl = $this->_getUrl('*/*/index', array('_secure' => true)); replace this code with your custom URL $successUrl = $this->_getUrl('costomURL', array('_secure' => true));

It works fine for me.