Get customer by custom attribute in Magento
Posted by navaneeth on May 27, 2015 in General, Magento, Php | No comments yet

We can get customer by custom attribute in magento with a single line of code as shown below, Just pass the attribute name and the desired value
<?php $customer=Mage::getModel('customer/customer')->getCollection()->addFieldToFilter('username', 'yourusernamehere')->load(); ?>
In the above code username is the desired custom attribute
and yourusernamehere is the value of the custom attribute
in $customer the customers matching the criteria will get as an array
hope this helps you to get customer by custom attribute in magento
Leave a Reply