1

I am creating a customer from the code for a specific group code created a new record in the customer_entity table but when I try to login from the website its shows invalid username or password error while the customer created from the magento admin panel working fine and login to the website and redirect to the account page. check my code below:

public function editAction()
{

    $oenologist = Mage::getModel('tandem_oenologistuser/oenologist');

    if ($oenologistId = $this->getRequest()->getParam('id', false)) 
    {
        $oenologist->load($oenologistId);

    }


    if ($postData = $this->getRequest()->getPost('oenologistData')) 
    {
        try {
            $oenologist->addData($postData);
            $oenologist->save();


            if(!$this->getRequest()->getParam('id'))
            {
                $name = $postData['name'];
                $email = $postData['email'];
                $password = '1234567';
                $groupId = 4;
                $websiteIdVal = 1;

                $websiteId = Mage::app()->getWebsite()->getId();
                $store = Mage::app()->getStore();

                $customer = Mage::getModel("customer/customer");
                $customer->setWebsiteId($websiteIdVal)
                         ->setStore($store)
                         ->setFirstname($name)
                         ->setEmail($email)
                         ->setPassword($password)
                         ->setGroupId($groupId)
                         ->setIsActive(1);

                try{
                    $customer->save();
                }
                catch (Exception $e) {
                    Zend_Debug::dump($e->getMessage());
                }

            }

            $this->_getSession()->addSuccess(
                    $this->__('The oenologist has been saved.')
                );


            return $this->_redirect(
                'tandem_oenologistuser_admin/oenologist/edit',
                array('id' => $oenologist->getId())
            );
        } catch (Exception $e) {
            Mage::logException($e);
            $this->_getSession()->addError($e->getMessage());
        }


    }


    Mage::register('current_oenologist', $oenologist);


    $oenologistEditBlock = $this->getLayout()->createBlock(
        'tandem_oenologistuser_adminhtml/oenologist_edit'
    );


    $this->loadLayout()
        ->_addContent($oenologistEditBlock)
        ->renderLayout();
}

Also, its add the website id to 0. I need to check the user on login for this specific group and redirect user to a custom controller action which is the user's custom profile page or is there any way i can customize the account page.

I have used the this link to create the users programmaticaly.

6
  • are customers getting email after save? Aug 30, 2016 at 9:01
  • right now its on my local machine Aug 30, 2016 at 9:06
  • are you creating user in admin side? Aug 30, 2016 at 9:28
  • @QaisarSatti : users created from the admin->customers->manage customers->add new customer can login the website but I am creating user from the custom module for a specific group those users are unable to login on the website. Aug 30, 2016 at 9:32
  • i am asking it is frontend or backend? Aug 30, 2016 at 9:33

1 Answer 1

1

Normally this is happens when you are creating user from admin panel. i have faced the similar situation once time.after the save i have to update the wesite to make user working

 $customer->save();
 $custid=$customer->getId();
 $customer = Mage::getModel('customer/customer')->load($custid);
 $customer->setWebsiteId(1);
 $customer->save();
5
  • I have updated my code above please check this is the custom admin manageable module add/edit action i am creating the user when new record added. Aug 30, 2016 at 9:39
  • you user problem will be solved after adding this code. because on creating the user it get default website id 0 so you have to update after save. Aug 30, 2016 at 9:41
  • Thanks again its working now. I need to check the user on login for this specific group and redirect user to a custom controller action which is the user's custom profile page or is there any way i can customize the account page. Aug 30, 2016 at 9:56
  • 1
    yes there is alway a way post the question the community will provide the answer Aug 30, 2016 at 9:58
  • Can you please check my Question Aug 30, 2016 at 11:58

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.