I need to get customer id before login by custom attribute value in Magento 2.1.5, for login by username.


Please Try below code :

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $customerObj = $objectManager->create('Magento\Customer\Model\ResourceModel\Customer\Collection');
    $collection = $customerObj->addAttributeToSelect('*')
   echo $c_data[0]['entity_id']; 
  • @Bapu I have updated my answer please check. – Deexit Sanghani May 1 '17 at 9:13
  • Thanx deexit & manthan too – Birjitsinh Zala May 1 '17 at 9:36
  • Before login it secure or not? – Birjitsinh Zala May 1 '17 at 9:37
  • How we can get customer attribute collection in magento 2? Because i want to show on catalog price rule form. How i can achieve this? – Pramod Kharade Aug 3 '17 at 7:03
  • It always displays first record...seems it holds first record. – wakar Ahamad Aug 6 '20 at 11:19

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.