0

I am checking in my custom controller if customer is logged in or not if the customer clicks on register after registration it should redirect to my custom controller and continue the process. I am using customer_register_success it is executing but i am getting blank customer session in my custom function.Suggest me some solution. This my custom function

 public function getcustomerdata()
   {           
            if(Mage::getSingleton('customer/session')->isLoggedIn())
            {
                     $customerData = Mage::getSingleton('customer/session')->getCustomer();
                      echo $customerData->getId();
                       $name = $customerData->getFirstname();

            }
            return $name;

  }

My observer function is.

 public function doSomething($observer)
   {   
       $AccountController = $observer->getEvent()->getAccountController();
        $Customer = $observer->getEvent()->getCustomer();

  $session=Mage::getSingleton('customer/session'); 
  $session->setBeforeAuthUrl(Mage::getSingleton("mymodule/session")->getCompurl().'state_new/1');
if (!$Customer->getCustomerActivated()) {
}
else{
   //$session->setCustomerAsLoggedIn($Customer);
   $response1 = Mage::app()->getResponse(); // observers have event args



    $dataarray = Mage::getSingleton("mymodule/session")->getData_array();
    $sampleid=$dataarray['sampleid'];

    $state=$dataarray['state'];
    if($state==1)
    {
      $collection=Mage::getSingleton('mymodule/mymodule')->customisesaved($sampleid);
    if($collection)
    {
        $url=Mage::getUrl('mymodule/mymodule/customshow');
         Mage::log($url,null,"url.log");            
            Mage::app()->getFrontController()->getResponse()->setRedirect($url);
         Mage::app()->getResponse()->sendResponse();
         exit;
    }          

}

}
}

1 Answer 1

0

You can use event to call your function after registration

<config><frontend>
<events>
  <customer_register_success>
    <observers>
      <your_module>
        <type>singleton</type>
        <class>your_module/observer</class>
        <method>yourMethod</method>
      </your_module>
    </observers>
  </customer_register_success>
</events></frontend></config>

public function yourMethod($observer)
{
    $customer = $observer->getCustomer();
}
5
  • thanks for your answer I have used this observer but I am getting blank session inside my custom function.
    – coder
    Aug 31, 2016 at 5:58
  • Please post your code which you are using to get session. Aug 31, 2016 at 6:02
  • Please check my update question.
    – coder
    Aug 31, 2016 at 6:07
  • Try with improved answer. Aug 31, 2016 at 6:16
  • check my updated question
    – coder
    Aug 31, 2016 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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