1

At the moment, I have an observer that fires on the customer_register_success event. this observer comes with a property ["customer"]. Is there a way to retrieve the email + password from this object, without modifying the core Magento code?

Basically, the use case is that a non Magento account must be created at another application, whenever a new customer registers through the Magento store.

I appreciate any help!

2

You can retrieve the customer data like this.

$customer = $observer->getCustomer();
$data = $customer->getData();
// Examine $data

However, I think the password is hashed at this point. Take a look at $data first and go from there. If it's not possible to retrieve password, you can create another observer that hooks onto an event where the password is still plain, cache it in the observer, and retrieve it in your observer that hooks onto the success event.

  • Hi musicliftsme, thank you for your advice. A customer object carrying a lot of protected properties is passed through the $observer object, in this event observer. There's a non-hashed password field in there, would you know if there's a way to access this protected property without messing with the Magento core code? – bamboo_inside Mar 17 '15 at 20:36
2

bamboo_inside,You can get customer data from this event by using below observer code:

public function getCustomerData($observer){
    $customer = $observer->getEvent()->getCustomer();
    $account_controller = $observer->getEvent()->getAccountController();
    print_r($customer->getData());
}

customer_register_success event only trigger when customer is register through magento frontend ui.See at class Mage_Customer_AccountController.

protected function _dispatchRegisterSuccess($customer)
    {
        Mage::dispatchEvent('customer_register_success',
            array('account_controller' => $this, 'customer' => $customer)
        );
    }

As you register through other applications, it does not work

Note that: this event occurs when the customer is registering through customer/account/createpost

  • Hello Amit, thanks for your help. Actually I'm trying to achieve the opposite. Create an account on another application after* the Magento registration is successful. – bamboo_inside Mar 17 '15 at 20:39
  • 1
    @bamboo_inside be sure to threat the customerdata carefully. By exchanging insecure passwords with external platforms you have a extra risk on security breaches. You can also think about using Magento as a SSO platform. – Jeroen Mar 19 '15 at 20:18

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.