How to Save Custom Attribute Value After Customer Register In Magento2?

April 30, 2020
April 30, 2020 yogita khasturi

How to Save Custom Attribute Value After Customer Register In Magento2?

In this article, 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 add customer attribute programmatically in magento2. Now let’s see:

Steps to save customer attribute in Magento2:

Step 1:

Firstly, create  app\code\Webiators\CustomerAttribute\etc\events.xml

Step 2:

Now create, app\code\Webiators\CustomerAttribute\ Observer\Customer\RegisterSuccessObserver.php file and add this code:

In this above code, we have set customer attribute name as ‘magento_username‘ and value as ‘Test‘.

That’s it!

If you have any issues in this topic feel free to mention them in the comment section below.

Thank you.