{"id":1429,"date":"2020-11-29T13:55:16","date_gmt":"2020-11-29T13:55:16","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-custom-customer-attribute-registration-form-magento-2\/"},"modified":"2025-07-17T10:21:56","modified_gmt":"2025-07-17T04:51:56","slug":"add-custom-customer-attribute-registration-form-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-custom-customer-attribute-registration-form-magento-2\/","title":{"rendered":"How to Add Custom Customer Attribute in Registration Form in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Online store owners are always trying to collect maximum customer information which can be used for marketing purposes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a business owner, knowing your customer is important in order to offer the best products, services, and customer experience that makes them a loyal customer for life.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, what type of information is required varies from business to business. Hence, you need to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-custom-customer-attribute-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">create custom customer attribute in Magento 2&nbsp;<\/a>based on your business requirements. You can&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/enable-middle-name-in-registration-form-in-magento-2\/\">Enable Middle Name in Registration Form<\/a>&nbsp;to add middle name as custom attribute for the one who are willing for it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, mobile number, interest\/hobbies, images, GST number, etc. can be created which are not a part of default\u00a0Magento 2\u00a0customer attributes but are important for your business to know your customers. Similarly, to\u00a0<a href=\"https:\/\/meetanshi.com\/blog\/show-tax-vat-number-in-registration-form-in-magento-2\/\">show Tax\/VAT Number in Registration Form in Magento 2<\/a>\u00a0can be an important custom attribute for businesses to collect relevant information from customers and ensure seamless transactions while adhering to tax laws.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, after creating a custom customer attribute, you can add it to the signup page where all the customer details are collected. For example you can&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-date-of-birth-in-registration-form-in-magento-2\/\">add date of birth in registration form<\/a>&nbsp;to identify customers age group and consider it as an custom attribute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial explains how you can&nbsp;<strong>add custom customer attribute in registration form in Magento 2<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Add Custom Customer Attribute in Registration Form in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create&nbsp;<strong>customer_account_create.xml&nbsp;<\/strong>at&nbsp;<em><strong>app\/code\/[Vendor]\/[Module]\/view\/frontend\/layout&nbsp;<\/strong><\/em>or for theme&nbsp;<strong><em>app\/design\/frontend\/Theme\/thememodule\/Magento_Customer\/layout<\/em><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"1column\"\n      xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;body>\n        &lt;referenceContainer name=\"form.additional.info\">\n            &lt;block class=\"Magento\\Framework\\View\\Element\\Template\" name=\"form_additional_info_customer_custom_attribute\"\n                   template=\"Vendor_Module::additionalInfo.phtml\"\/>\n        &lt;\/referenceContainer>\n    &lt;\/body>\n&lt;\/page><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create&nbsp;<strong>additionalInfo.phtml<\/strong>&nbsp;at&nbsp;<em><strong>app\/code\/[Vendor]\/[Module]\/view\/frontend&nbsp;<\/strong><\/em>templates or for theme&nbsp;<strong><strong><em>app\/design\/frontend\/Theme\/thememodule\/Magento_Customer\/templates<\/em><\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"field required\">\n    &lt;label class=\"label\" for=\"custom_attribute\">\n        &lt;span>&lt;?php echo __('Custom Attribute');?>&lt;\/span>\n    &lt;\/label>\n    &lt;div class=\"control\">\n        &lt;input type=\"text\" name=\"custom_attribute\" id=\"custom_attribute\" value=\"\"\n               title=\"&lt;?php echo __('Custom Attribute'); ?>\" class=\"input-text\" data-validate=\"{required:true}\">\n    &lt;\/div>\n&lt;\/div><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it. It was simple. Isn\u2019t it?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You may also love to read our blog post on&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-custom-order-attribute-in-magento-2-and-show-it-in-admin-grid\/\" target=\"_blank\" rel=\"noreferrer noopener\">create a custom order attribute in Magento<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do consider sharing this post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Online store owners are always trying to collect maximum customer information which can be used for marketing purposes. As a business owner, knowing your customer&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"predecessor-version":[{"id":14603,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1429\/revisions\/14603"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}