Magento 1.6 – How to Check if Customer is Subscribed to Newsletter

ce-1.6.2.0customermagento-1.6newsletter

I need to check if the customer is subscribed to news letter or not. Currently I am using this code and it is returning nothing:

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
    $status = Mage::getSingleton('customer/session')->getCustomer()->getIsSubscribed();
    echo $status;
    die();
}

This is not giving anything. Any idea how to get this to work?

Best Answer

Alternatively you can try this, if you have the customer's email address:

$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
if ($subscriber->getId()) {
     // put your logic here...
}

Or if you have customer ID then you can directly check in newsletter_subscriber table to check if customer ID exists or not.

Related Topic