4

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?

4

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

2
  • That is for customer address. But here I'm trying to add new field to admin user in the admin panel. – Saravanan Sampathkumar Jun 13 '14 at 4:02
  • You just need to set it according to your requirement. – Haris Jun 13 '14 at 4:30
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.