Search code examples
magentonewslettersubscriber

Show CMS block only for customers who have not subscribed to a Newsletter


I'm looking for a way to show a CMS block only to customers (who are logged in anyways) who have not subscribed for the newsletter.

Could someone help me with the code? I know how to implement the CMS block, just not sure how to check whether the customer has subscribed already or not.

Thanks a lot, Johannes


Solution

  • Magento is check a customer email exits or not by below code

    $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
    $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
     if($subscriber->getId())
     {
    	if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
    	   // 'Confirmation request has been sent.';
    	}
    	else {
    	    //Thank you for your subscription;
    	}
    }
    else{
    
    //no subcription
    }