What I want

  • add customer attribute
  • show the new attribute in front(dashboard) page


I have created customer attribute with this code below:

define('MAGENTO', realpath(dirname(__FILE__)));

require_once MAGENTO . '/app/Mage.php';


$installer = new Mage_Customer_Model_Entity_Setup('core_setup');


$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);

$installer->addAttribute('customer', 'manager', array(
        'label' => 'Account Manager',
        'input' => 'text',
        'type'  => 'varchar',
        'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
            'visible' => true,
            'global' => true,
            'visible_on_front' => 1,
        'required' => false,
        'default_value' => 'default',
        'user_defined' => true,

$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'manager', 0);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'manager');
$oAttribute->setData('used_in_forms', array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'));

echo "DONE";

And then, this part was normally works. I can find new form in backend and I can update the form with new data. That was good so far but I couldn't get the data in front page section.

When I have searched this problem, the below code seems to normally working but it wasn't work for me.

I put below code in /app/design/frontend/<Theme>/default/template/customer/account/dashboard.phtml.

$attr = $this->getCustomer()->getAttribute('manager')->getData($customer);
// not working

$customer = Mage::getSingleton('customer/session')->getCustomer();
$attr = $customer->getAttribute('manager')->getData($customer);
// not working

$_customerModel = Mage::getModel('customer/customer');
$_customer = $customerModel->load($this->getCustomer()->getId());
$attr = $_customer->getAttribute('manager')->getData($_customer);
// Yeah, still not working

$attr = $this->getCustomer()->getAttribute('manager')->getData('manager');
// not working but getData('firstname') is working

I think the custom attribute was not fully loaded when the customer loaded. Also it seems to be problem with new version of magento. I couldn't find same problem anywhere.

Can I get the data by force such as connecting to database directly or am I missing something in this code?

3 Answers 3


you can get the value of the customer attribute in this way:

$customerObj  = Mage::getModel('customer/customer')->load($customer_id);
$attr = $customerObj->getData('manager');
  • Thanks for your answer but that's a same code what I tried. By the way, is it right the code for creating attribute?
    – Edward
    Commented Apr 7, 2014 at 23:20
  • Sorry. I solved it. You're right. I mean, it was correct. I've got a wrong user information.
    – Edward
    Commented Apr 7, 2014 at 23:46
  • no problem, I am glad it helped. Cheers! Commented Apr 8, 2014 at 5:46
  • how to set data?
    – Black
    Commented Sep 11, 2018 at 11:46

You should try This link

to create customer attriube.

Just open above link and create module for your customer attribute as Need Add Customer Attribute wity yes it will ask detail for your attribute and it's ready to use with your magento.

Eg. if you are creating your attribute like manager then just add fill the form and create your module.then after you will get your attribute value with cusotomer model like$customer->getManager().


Refer the below mentioned coding for Get Logged In Customer’s details

//Check if any customer is logged in or not

if (Mage::getSingleton('customer/session')->isLoggedIn()) {

    // Load the customer's data
    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $customer->getName(); // Full Name
    $customer->getFirstname(); // First Name
    $customer->getMiddlename(); // Middle Name
    $customer->getLastname(); // Last Name

    // All other customer data
    $customer->getWebsiteId(); // ID
    $customer->getEntityId(); // ID
    $customer->getEntityTypeId(); // ID
    $customer->getAttributeSetId(); // ID
    $customer->getGroupId(); // ID
    $customer->getStoreId(); // ID
    $customer->getCreatedAt(); // yyyy-mm-ddThh:mm:ss+01:00
    $customer->getUpdatedAt(); // yyyy-mm-dd hh:mm:ss
    $customer->getIsActive(); // 1
    $customer->getCreatedIn(); // Admin
    $customer->getGender(); // ID
    $customer->getDefaultBilling(); // ID
    $customer->getDefaultShipping(); // ID
    $customer->getDob(); // yyyy-mm-dd hh:mm:ss
    $customer->getTaxClassId(); // ID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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