Newsletter Auto Subscription To Mailing List

Hi,



I’m using 4.2.1 (responsive theme). Is there a way that when a customer enters their email in our newsletter signup box on the main page that it adds them directly to a specific mailing list?

Hello,



Some code modifications are required in order to implement this.

[quote name='SwimShady' timestamp='1408661929' post='190250']

Hi,



I'm using 4.2.1 (responsive theme). Is there a way that when a customer enters their email in our newsletter signup box on the main page that it adds them directly to a specific mailing list?

[/quote]



If you wish we are free to develop it for you.

[quote name='SwimShady' timestamp='1408661929' post='190250']

Hi,



I'm using 4.2.1 (responsive theme). Is there a way that when a customer enters their email in our newsletter signup box on the main page that it adds them directly to a specific mailing list?

[/quote]



In the app/addons/news_and_emails/controllers/frontend/newsletters.php you can find the following code in the add_subscriber mode:



list($lists) = fn_get_mailing_lists();
fn_update_subscriptions($subscriber_id, array_keys($lists), NULL, fn_get_notification_rules(true));




You can change array_keys($lists) with array(X), the X is the ID of the required mailing list. For example,



fn_update_subscriptions($subscriber_id, array(1), NULL, fn_get_notification_rules(true));

[quote name='eComLabs' timestamp='1408693450' post='190279']

In the app/addons/news_and_emails/controllers/frontend/newsletters.php you can find the following code in the add_subscriber mode:



list($lists) = fn_get_mailing_lists();
fn_update_subscriptions($subscriber_id, array_keys($lists), NULL, fn_get_notification_rules(true));




You can change array_keys($lists) with array(X), the X is the ID of the required mailing list. For example,



fn_update_subscriptions($subscriber_id, array(1), NULL, fn_get_notification_rules(true));


[/quote]



Thanks eCom. I did those changes then tried it, but it didn't work. So I reverted back to the original code, and for some reason that doesn't work either. So you're code probably works, but there's something else causing the issue. I never used the subscribe to newsletters button in the past, I would always enter subscribers manually in the admin because of the type of business I have. So maybe it's never worked, I just never knew. It doesn't even add the email to the database, just refreshes the page when I hit the submit button.



I'll have to look into it further.



Thanks for you help!

[quote name='SwimShady' timestamp='1408716855' post='190331']

Thanks eCom. I did those changes then tried it, but it didn't work. So I reverted back to the original code, and for some reason that doesn't work either. So you're code probably works, but there's something else causing the issue. I never used the subscribe to newsletters button in the past, I would always enter subscribers manually in the admin because of the type of business I have. So maybe it's never worked, I just never knew. It doesn't even add the email to the database, just refreshes the page when I hit the submit button.



I'll have to look into it further.



Thanks for you help!

[/quote]



A minute after I wrote my last comment, I figured out what the issue was…



I have an add-on that customers need to be logged in to view my products and the majority of the website, so I was trying to subscribe to the newsletter from the login (auth) page. So most pages and commands are blocked unless you're logged in (hence why is wasn't working). I want the newsletter to only be available to people that are NOT logged in. Thankfully the add-on lets me put lists of commands and webpages that I want to work for unlogged customers (eg. “newsletters.add_subscriber”)… And it worked!



Thanks eCom!

[quote name='SwimShady' timestamp='1408718038' post='190334']

Thanks eCom!

[/quote]



Thank you for letting us know it! We are glad to help you