Magento – Programmatically Subscribe and Unsubscribe Newsletter Subscribers

Published 2 Comments on Magento – Programmatically Subscribe and Unsubscribe Newsletter Subscribers

The following can be a handy snippet. Its usage and placement is totally up to your imagination and requirements.

[php]
/* To Subscribe */
Mage::getModel(‘newsletter/subscriber’)->subscribe(‘[email protected]’);
/* To Unsubscribe */
Mage::getModel(‘newsletter/subscriber’)->loadByEmail(‘[email protected]’)->unsubscribe();
[/php]

2 comments

    1. @magormenessy:disqus that’s highly dependent on your scenario. Are you looking to automatically subscribe people when they create an account? Do you simply have a list of emails you’d like to subscribe? Are you looking to subscribe someone after submitting a contact form? etc. etc.

Comments are closed.