I need to add a custom field to the user account information while creating a user under
system > permission > user > add new user
I need to add a "location" field along with firstname, lastname, email and password fields.
how can I do this?
1- This tutorial may help you, it does exact the same thing you want but just for customer account Add Custom Field to Customer Address
2- Another rough method is that you override the magento core files,
-> app/code/core/mage/adminhtml/block/permissions/users/edit/tab/main.php
and add your desired field
and then goto database admin_user
table and add that field there
You will need to add a column to the admin_user
table.
$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'location', array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'length' => 256,
'nullable' => true,
'default' => null
));
Then, if you want to add/edit this field from the backend you need to rewrite the method Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Main::_prepareForm
and add a new element in there:
$fieldset->addField('location', 'select', array(
'name' => 'is_active',
'label' => Mage::helper('adminhtml')->__('location'),
'id' => 'is_active',
'title' => Mage::helper('adminhtml')->__('location'),
'class' => 'input-select',
'style' => 'width: 80px',
'options' => array('1' => Mage::helper('adminhtml')->__('Yes'), '0' => Mage::helper('adminhtml')->__('No')),
));
Clear the cache and it should work.