I wish to create new fields in the customer registration form. I just wanted to know whether there is any option to create it from Magento admin panel.
Kindly guide me as am new to magento.
No, There is no option to create it from admin. You will need to create custom script to create it. You can follow below module steps to create custom attribute.
app/code/local/Custom/Customerattribute/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Custom_Customerattribute>
<version>0.1.0</version>
</Custom_Customerattribute>
</modules>
<global>
<resources>
<customerattribute_setup>
<setup>
<module>Custom_Customerattribute</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customerattribute_setup>
<customerattribute_write>
<connection>
<use>core_write</use>
</connection>
</customerattribute_write>
<customerattribute_read>
<connection>
<use>core_read</use>
</connection>
</customerattribute_read>
</resources>
</global>
</config>
app/code/local/Custom/Customerattribute/sql/customerattribute_setup/mysql4-install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("customer", "custom_attribute", array(
"type" => "varchar",
"backend" => "",
"label" => "Custom Attribute",
"input" => "text",
"source" => "",
"visible" => true,
"required" => false,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "custom_attribute");
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();
$installer->endSetup();
And finally declare your module
app/etc/modules/Custom_Customerattribute.xml
<?xml version="1.0"?>
<config>
<modules>
<Custom_Customerattribute>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Custom_Customerattribute>
</modules>
</config>
You can change your attribute code and label as per your requirement.
I do not have the rep to comment, so I had to answer.
There is no way from admin panel as such. But you can do that custom
I am assuming it for magento 1. And I think the question is already shared in the post:-
You did not explained is it for Magento 2, or Magento 1
Answer he shared:-
To allow to publish an attribute in the register form and some others form page, you have to set that the attribute(s) is/are available to those forms.
To do that here is a sample code to put in your sql setup below. You can find the rest of the code I used for my Magento Username module on my github account.
/* @var $installer Diglin_Username_Model_Entity_Setup */
$installer = $this;
/* @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
$store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$attributes = $installer->getAdditionalAttributes();
foreach ($attributes as $attributeCode => $data) {
$installer->addAttribute('customer', $attributeCode, $data);
$attribute = $eavConfig->getAttribute('customer', $attributeCode);
$attribute->setWebsite( (($store->getWebsite()) ? $store->getWebsite() : 0));
if (false === ($attribute->getIsSystem() == 1 && $attribute->getIsVisible() == 0)) {
$usedInForms = array(
'customer_account_create',
'customer_account_edit',
'checkout_register',
);
if (!empty($data['adminhtml_only'])) {
$usedInForms = array('adminhtml_customer');
} else {
$usedInForms[] = 'adminhtml_customer';
}
if (!empty($data['adminhtml_checkout'])) {
$usedInForms[] = 'adminhtml_checkout';
}
$attribute->setData('used_in_forms', $usedInForms);
}
$attribute->save();
}