I'm using magento 2.1.7 EE and customer custom attributes creation in built, so I have added three attributes customer_title, customer_type and industry_type

So I want to display all three categories separately in my desired places. Still didn't find a way to show it.

Following section shows the all customer custom attributes together.

<?php $customerAttributes = $block->getChildBlock('customer_form_user_attributes'); ?>
<?php if ($customerAttributes): ?>
<?php $customerAttributes->setEntityType('customer')->setShowContainer(false);?>
<?php $block->restoreSessionData($customerAttributes->getMetadataForm());?>
<?php echo $customerAttributes->toHtml()?>
<?php endif;?>

Need help.

  • @akgola do you have any idea about this?
    – Lasantha
    May 23, 2018 at 17:26

1 Answer 1


I'm waiting 5 days for an answer, finally I found a shortcut. So I think better to post it here.

This will helpful to developer who needs to customize the register post.

Register page show Customer attribute as follows,

$customerAttributes = $block->getChildBlock('customer_form_user_attributes');

if ($customerAttributes): 
  echo $customerAttributes->toHtml(); // Here display the all customer attributes

So I found the getUserDefinedAttributes() method checking the module block,

then modified the code as,

if ($customerAttributes): 
  // Read the all customer attributes.
  foreach ($customerAttributes->getUserDefinedAttributes() as $attribute):
    // Check the attribute code and I want to show customer_title so filter it using if.
    if($attribute->getAttributeCode() == "customer_title"):
      // get attribute content using filtered $attribute
      $attributeContent = $customerAttributes->getAttributeHtml($attribute);
      if ($attributeContent):
        echo $attributeContent; // Display customer_title attribute content

This helps for customer address attributes also.

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.