Hello Magento Folks?,
How are you all going on? Welcome again in our latest article of How To Series for Magento 2 where we are going to understand How to Save Custom Attribute Value After Customer Register Successful in Magento 2. Previously, we have learned about How to Check If Magento 2 is Running In Production Mode with all the required codes.
Basically, Magento 2 is very flexible to use and the development of your own attributes according to your requirements is easily created. Here, in this article, I will explain to you about How to add a custom Attribute and save the value after the customer register Successful with the help of appropriate codes for it. Let’s Get In?.
Steps to Code:
Firstly, create app\code\Vendor\Extension\view\events.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<observer name="event_customer_register_success" instance="Vendor\Extension\Observer\Customer\RegisterSuccessObserver" />
Now create, app\code\Vendor\Extension\ Observer\Customer\RegisterSuccessObserver folder and add this code:
class RegisterSuccessObserver implements ObserverInterface
public function __construct(
$this->customerRepository = $customerRepository;
public function execute(\Magento\Framework\Event\Observer $observer)
$customer = $observer->getEvent()->getCustomer();
After performing the above step you can easily save your custom attribute on Customer Registration in Magento 2.
I hope the above-given explanation about How to Save Custom Attribute Value After Customer Register Successful in Magento was helpful for all. For more articles like this do comment on your programmatically issues in Magento 2 in the comment section below. If you find any difficulties in performing the above steps then feel free to contact our Support Team. And if you find the blog interesting then do share with your Magento friends and help them.
Stay Home? Stay Safe!
Happy Coding 🙂
Good Morning Sir!
I change variable and work!
Should your events.xml file have been in the etc/ folder instead of view/?