This one’s a little un-intuitive. At first.
There are times where you’ll want to programmatically check if a customer is confirmed. To do this you’d instantiate a customer object like this
$customer = Mage::getModel('customer/customer')->getCollection() ->addFieldToFilter('entity_id','197') ->getFirstItem();
or like this
$customer = Mage::getModel('customer/customer')->load(197); $customer = Mage::getModel('customer/customer')->loadByEmail('email@example.com');
However, if you dump out the data of a confirmed customer,
var_dump($customer->getData()); var_dump($customer->getConfirmation()); var_dump($customer->getData('confirmation'));
you won’t see a
confirmation value. Maybe it’s EAV, so you add all the attributes to the select
$customer = Mage::getModel('customer/customer')->getCollection() ->addFieldToFilter('entity_id','197') ->addAttributeToSelect('*') ->getFirstItem();
Still Nothing. You might spent a lot of time cursing EAV and listeners, wondering where-the-heck the confirmation value is stored, and how-the-heck you’re supposed to load it from a customer object.
However, if you load a customer that hasn’t been confirmed and dump out the object’s data, you’re going to see something like this
'confirmation' => string '700df1' (length=6)
which is a hint to what’s really going on.
There is a
confirmation attribute associate with each object, but (in retrospect) it should have been named
confirmation_key. Magento uses the attribute to store the key value that’s passed into the system when a customer click the confirmation link in their email.
That means if there’s a value in
confirmation, then the customer is not confirmed, meaning if
confirmation is empty then the customer is confirmed. The reason you don’t see any value in there for a confirmed customer is Magento removes the value after a customer is confirmed, so there’s nothing for EAV to load.
A little counter intuitive, but once you understand the intent of the attribute (store the confirmation key), it makes a lot more sense.