Skip to main content

This work for Magento 1

<?php 
       class Exinent_Billingtax_Model_Observer 
       {
            public function autoRegisterBilling($evt){
                if(!Mage::helper('customer')->isLoggedIn()){
                    $data =$evt->getEvent()->getControllerAction()->getRequest()->getPost('billing', array());
                echo "<pre>";
                print_r($data);
                $customer = Mage::getModel("customer/customer");
                $email = $data['email'];
                $websiteId = Mage::app()->getWebsite()->getId();
                $store = Mage::app()->getStore();
                $pwd = $data['customer_password'];
                $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
    
                if (!$customer->getId()) {
                     //Code begins here for new customer registration
                    $customer->website_id = $websiteId;
                    $customer->setStore($store);
                    $customer->firstname = $data['firstname'];
                    $customer->lastname = $data['lastname'];
                    $customer->setEmail($email);
                    $customer->setPassword($pwd);
                    $customer->sendNewAccountEmail('confirmed');  
                    $customer->save();
                       }
                Mage::getSingleton('customer/session')->loginById($customer->getId()); // to login that customer.
               }
        }
    
    }

}

This work for Magento 1

<?php class Exinent_Billingtax_Model_Observer {
public function autoRegisterBilling($evt){
    if(!Mage::helper('customer')->isLoggedIn()){
        $data =$evt->getEvent()->getControllerAction()->getRequest()->getPost('billing', array());
        echo "<pre>";
        print_r($data);
        $customer = Mage::getModel("customer/customer");
        $email = $data['email'];
        $websiteId = Mage::app()->getWebsite()->getId();
        $store = Mage::app()->getStore();
        $pwd = $data['customer_password'];
        $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);

        if (!$customer->getId()) {
             //Code begins here for new customer registration
            $customer->website_id = $websiteId;
            $customer->setStore($store);
            $customer->firstname = $data['firstname'];
            $customer->lastname = $data['lastname'];
            $customer->setEmail($email);
            $customer->setPassword($pwd);
            $customer->sendNewAccountEmail('confirmed');  
            $customer->save();
               }
        Mage::getSingleton('customer/session')->loginById($customer->getId()); // to login that customer.
       }
}

}

This work for Magento 1

<?php 
       class Exinent_Billingtax_Model_Observer 
       {
            public function autoRegisterBilling($evt){
                if(!Mage::helper('customer')->isLoggedIn()){
                    $data =$evt->getEvent()->getControllerAction()->getRequest()->getPost('billing', array());
                echo "<pre>";
                print_r($data);
                $customer = Mage::getModel("customer/customer");
                $email = $data['email'];
                $websiteId = Mage::app()->getWebsite()->getId();
                $store = Mage::app()->getStore();
                $pwd = $data['customer_password'];
                $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
    
                if (!$customer->getId()) {
                     //Code begins here for new customer registration
                    $customer->website_id = $websiteId;
                    $customer->setStore($store);
                    $customer->firstname = $data['firstname'];
                    $customer->lastname = $data['lastname'];
                    $customer->setEmail($email);
                    $customer->setPassword($pwd);
                    $customer->sendNewAccountEmail('confirmed');  
                    $customer->save();
                       }
                Mage::getSingleton('customer/session')->loginById($customer->getId()); // to login that customer.
               }
        }
    
    }
Source Link

This work for Magento 1

<?php class Exinent_Billingtax_Model_Observer {
public function autoRegisterBilling($evt){
    if(!Mage::helper('customer')->isLoggedIn()){
        $data =$evt->getEvent()->getControllerAction()->getRequest()->getPost('billing', array());
        echo "<pre>";
        print_r($data);
        $customer = Mage::getModel("customer/customer");
        $email = $data['email'];
        $websiteId = Mage::app()->getWebsite()->getId();
        $store = Mage::app()->getStore();
        $pwd = $data['customer_password'];
        $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);

        if (!$customer->getId()) {
             //Code begins here for new customer registration
            $customer->website_id = $websiteId;
            $customer->setStore($store);
            $customer->firstname = $data['firstname'];
            $customer->lastname = $data['lastname'];
            $customer->setEmail($email);
            $customer->setPassword($pwd);
            $customer->sendNewAccountEmail('confirmed');  
            $customer->save();
               }
        Mage::getSingleton('customer/session')->loginById($customer->getId()); // to login that customer.
       }
}

}