1

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

  • Do You have a seperate form or you are talking about the customer registration form provided by magento? Please share your problem in more detail with code snippet if possible. This will help you get answers faster. – aton1004 Nov 10 '17 at 8:29
  • Iam having verifiacation code form – Nadh Nov 10 '17 at 8:31
  • So you have a custom form and on form submission you want to redirect it to home page? Is that what you want? – aton1004 Nov 10 '17 at 8:32
  • yes for submission of registration it will go to my custom form and then it will go to homepage – Nadh Nov 10 '17 at 8:37
  • Could you please update your question with screenshots on what is happening right now and what you want to achieve? Your comments are not helping at all, sorry :( – aton1004 Nov 10 '17 at 8:40
0

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("/");
  • can you give the proper answer – Nadh Nov 10 '17 at 8:31
0

If I get you correctly, On customer registration success you want your customer to be redirected to the page with template verify.phtml. When the verification is successful you want them to be redirected to Home page.

For this I think you should follow below steps:

  1. override customer create Action of Account controller, some information could be found here
  2. On the controller action you need to set the redirect to your customer module controller which will load the layout that has a block with your template of verify.phtml

I think point 2 may confuses you. So let me explain a bit more in detail.

First of all you need your own module with a controller. in that controller You will load and render a layout with template. Refer this

Now on the same module you could override the customer controller with create Action. And there after customer is created, you can redirect to your controller by doing something like

$this->_redirect('module-frontname/controller-name/action-name');

You can search more detail about redirecting to our custom module controller.

On the verify form submission success, which you are doing through ajax, you can redirect easily to your home page.

I hope my answer above provide you some giudelines to move ahead. If it helps you please accept and vote up the answer.

Happy Coding!!

  • can you give steps in sample code – Nadh Nov 10 '17 at 12:20

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.