I want to get newly registered users' data on the customer_register_success event for integration purposes with other CMS to push it there so as I'm new to Magento development I want some help on how and where to code my process upon that customer_register_success event.

appreciate any further help.


Create a custom module and then declare events in VendorName\ModuleName\etc\events.xml by putting below code:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
  <event name="customer_register_success">
    <observer name="customer_resgister_observer" instance="VendorName\ModuleName\Observer\GetCustomerDetails" />

Then create the observer class in VendorName\ModuleName\Observer\GetCustomerDetails.php and put the below code:

namespace VendorName\ModuleName\Observer;

use Magento\Framework\Event\ObserverInterface;

class GetCustomerDetails implements ObserverInterface
  protected $_customerRepositoryInterface;

  public function __construct(
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface
) {
    $this->_customerRepositoryInterface = $customerRepositoryInterface;

 public function execute(\Magento\Framework\Event\Observer $observer)
    $customer = $observer->getEvent()->getCustomer();
  • why you add the contructor ? when $customerRepositoryInterface has never been used ? any reason – Dexture Dec 26 '18 at 11:19
  • This is because to demonstrate the constructor implementation in the observer if needed someone. – Prasanta Hatui Dec 26 '18 at 11:25

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.