Magento 1.9 – How to Redirect Custom Page After Registration and Then Home Page

customer-registrationmagento-1.9redirect

How to redirect custom page after registration in Magento 1.9.2.4. In my custom page having the form if I submit that form ,then it will go to home page

I have verify.phtml

             <?php 

               $isuserVerified = Mage::helper('test/Data')->isUserVerified(Mage::getSingleton('customer/session')->getId());
              if($isuserVerified == 'false'): ?>
        <div class="verify_mobile">
            <?php /*?><div class="notverify_yet">
       <?php echo $this->__('*Please verify your mobile with OTP code.'); ?>

<label class="verify">
    <?php echo $this->__("Please Enter verification codes"); ?>
</label>
<input type="text" id="code" name="code" placeholder="Enter verification code" class="verify" />
<input type="button"  id="verify_mobile" value="Verify Mobile" class="button verify" />
<?php if(Mage::helper('test/Data')->canResendOTP())
    { ?>
<a href="#" id="resend_mobile_code" class="verify resendcode">Resend Code</a>
<?php } ?>

                    <script type="text/javascript">
                 jQuery(document).ready(function(e) {

    jQuery('#verify_mobile').click(function(e) {
        var code = jQuery("#code").val();
        if(code !== ""){
            jQuery.ajax({
                method:"POST",
                url:'<?php echo Mage::getBaseUrl().'test/index/checkMobileVerificationCode' ?>',
                data:{code:code}, 
                success: function(data) {

                    if(data !== "false"){
                        jQuery(".verify_mobile").css('display','none');
                        showMessage('Thanks for Verification', "success");
                    }
                    else
                    {
                      showMessage('Please Enter Valid Code!', "error"); 
                    }
                },
                error: function() {
                    alert('Error occured');
                }
            });
        }
    }); 

    jQuery('#resend_mobile_code').click(function(e) {
        var code = jQuery("#code").val();

        jQuery.ajax({
            method:"POST",
            url:'<?php echo Mage::getBaseUrl().'test/index/resendMobileCode' ?>',
            success: function(data) {

                showMessage(data, "success");
            },
            error: function() {
                showMessage('Something went wrong', "error");
            }
        });
    }); 

    function showMessage(txt, type) {
        var html = '<ul class="messages"><li class="'+type+'-msg"><ul><li><span>' + txt + '</span></li></ul></li></ul>';
        jQuery('ul.messages').remove();
        jQuery('.page-title').after(html);
    }

});

I want to call this page(verify otp) after successful registration and after successful verification otp it will go to home page.

I tried with create custom module observer

         <?php
class Tst_Custommodule_Model_Observer {
    public function myredirection(Varien_Event_Observer $observer) {
    //echo "fsdffds";exit;
    $AccountController = $observer->getEvent()->getAccountController();

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

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

        $url = 'numberverify';
        $response1->setRedirect($url);
        Mage::app()->getFrontController()->sendResponse();

    return;
  }
} 

but it gets error cannot save customer

Best Answer

You can use following code in your observer which will observe event customer_register_success

 Mage::app()->getResponse()->setRedirect('frontname/controller/action');
 Mage::app()->getResponse()->sendResponse();

For redirecting back to home page you can use following in you form's submit controller you can use following code ;

$this->_redirect("/");
Related Topic