How to get customer custom attributes in Magento 2?

You can use the below code for getting the custom customer attribute

how-to-get-customer-custom-attribute-in-magento-2expoundsofttechsolution



$customerID = 10;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerrepo = $objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface');
$customer = $customerrepo->getById($customerID);
echo $customer->getCustomAttribute();

Please leave your comment for asking any question or suggestion.

Need Help?