daniels Posted April 13, 2018 Share Posted April 13, 2018 This is a lightweight alternative to other newsletter & newsletter-subscription modules. You can find the Module in the Modules directory and on Github It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin. This module fits your needs if you... ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk EDIT: Since 0.0.4, instructions and changelog can be found in the README only. You can find it here ? If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks! 15 Link to comment Share on other sites More sharing options...
szabesz Posted April 13, 2018 Share Posted April 13, 2018 Thanks for sharing! Link to comment Share on other sites More sharing options...
giannisok Posted April 21, 2018 Share Posted April 21, 2018 Thanks for sharing Daniels! It would be a good idea to make it backwards compatible with PHP 5.5 so that it works on older installations otherwise mention that it has PHP 7 dependency. Regards! 2 Link to comment Share on other sites More sharing options...
wbmnfktr Posted April 22, 2018 Share Posted April 22, 2018 I made it work with PHP 5.x just by changing one line. SubscribeToMailchimp.module - Line 23 - before: public function subscribe(string $email, array $data = [], string $list = "") { SubscribeToMailchimp.module - Line 23 - after: public function subscribe( $email, $data = [], $list = "") { This works without any problems so far. 3 Link to comment Share on other sites More sharing options...
daniels Posted April 24, 2018 Author Share Posted April 24, 2018 Hey, thanks for the feedback @giannisok and for the solution @wbmnfktr. I have just updated to version 0.0.2 with the ability to unsubscribe and delete users. I also removed the 'string' type declarations, hope it works now with your PHP version @giannisok . When I have the time I'll change my dev machine setup, so I can test with different PHP versions. But since I use Valet, I think I can only downgrade to php5.6 anyway. 3 Link to comment Share on other sites More sharing options...
Mikel Posted May 4, 2018 Share Posted May 4, 2018 Hi, Daniels, thanks for sharing this! I have just ran into an issue while testing: After successful initial subscription of an user, I could unsubscribe him again, but after that no more subscription of the same user would work. Is this due to a limitation of Mailchimp? Link to comment Share on other sites More sharing options...
jacmaes Posted May 4, 2018 Share Posted May 4, 2018 @Mikel Pretty sure you can’t subscribe to a list you previously unsubscribed from. It’s a Mailchimp “feature”. 1 Link to comment Share on other sites More sharing options...
daniels Posted May 4, 2018 Author Share Posted May 4, 2018 Hey @Mikel, seams like with the original mailchimp subscribe forms, it is possible (and in my opinion it should be) to resubscribe. I will have a look on that! Thanks for the input. Meanwhile (e.g. for testing) you can use the delete method to completely delete and resubscribe a user. That is working for me with the current version. 2 Link to comment Share on other sites More sharing options...
Mikel Posted May 4, 2018 Share Posted May 4, 2018 Just now, jacmaes said: @Mikel Pretty sure you can’t subscribe to a list you previously unsubscribed from. It’s a Mailchimp “feature”. Ok, thanks, I was not sure, so, in my special use case it will be better not to unsubscribe the user, but to delete him. So if he likes to subscribe again in the future, he will get added again. Link to comment Share on other sites More sharing options...
Mikel Posted May 4, 2018 Share Posted May 4, 2018 Just now, daniels said: Hey @Mikel, seams like with the original mailchimp subscribe forms, it is possible (and in my opinion it should be) to resubscribe. I will have a look on that! Thanks for the input. Meanwhile (e.g. for testing) you can use the delete method to completely delete and resubscribe a user. That is working for me with the current version. Thanks, thats just what I implemented and testet this moment. Working flawless :-) Link to comment Share on other sites More sharing options...
horst Posted May 8, 2018 Share Posted May 8, 2018 Hi @daniels, many thanks for that great module! As a little helper, I added a checkbox to the modules config page that can test the current settings. If you don't mind, I sent you a pull request. Spoiler 3 Link to comment Share on other sites More sharing options...
daniels Posted May 8, 2018 Author Share Posted May 8, 2018 @horst this is awesome!! Thank you, I will totally merge it in. It looks really great and is super helpful. I didn't even know, that this is possible via the module settings ? I also had a look at the issue mentioned by @Mikel . To resubscribe users (and I think this is indispensable) I had to add a getStatus method and change how the subscription method works. Now if a user resubscribes, he will get the double-opt-in mail again. I made a PR for this too, maybe you can take a look. I will merge both PRs than to version 0.0.3 (and hopefully don't mess it up .... :D) later this week. https://github.com/danielstieber/SubscribeToMailchimp/pull/2 3 Link to comment Share on other sites More sharing options...
Marco Ro Posted May 10, 2018 Share Posted May 10, 2018 Thank you for the modules. it's so great! I don't know if some one have already try but, Is it possible to integrate this in the loginRegister module? I try to looking in the validation process of the module but I think at moment need make an hook to ___processRegisterForm, is it correct? If yes How I can do the hook? thank you. Link to comment Share on other sites More sharing options...
daniels Posted May 11, 2018 Author Share Posted May 11, 2018 Thank you for the feedback @MarcoPLY I've not worked with loginRegister and hooks yet. If you or someone finds a solution, please share it in here ? 1 Link to comment Share on other sites More sharing options...
daniels Posted May 11, 2018 Author Share Posted May 11, 2018 I've created an issue regarding features of MailChimp, that currently can't be used with the module. Also I'd like to make it more flexible, if Mailchimp roles out new stuff. My question to you: Do you currently use this MailChimp features or would like to have it in the module? - Groups (Interests) (Setup up - VIP - manually fill IP, Language and/or Location 1 Link to comment Share on other sites More sharing options...
dragan Posted May 11, 2018 Share Posted May 11, 2018 25 minutes ago, daniels said: manually fill IP, Language and/or Location Not IP, but language / gender + location 1 Link to comment Share on other sites More sharing options...
flydev Posted May 11, 2018 Share Posted May 11, 2018 @MarcoPLY feel free to ask your question in this thread or this , as I am building a companion module for LoginRegister, all feature are welcome. 3 Link to comment Share on other sites More sharing options...
daniels Posted May 17, 2018 Author Share Posted May 17, 2018 I've just rolled out version 0.0.3 - checkout the changelog . You should be able to update without any changes in your code. 3 1 Link to comment Share on other sites More sharing options...
daniels Posted May 27, 2018 Author Share Posted May 27, 2018 Updated to version 0.0.4 - checkout the changelog . The Github user ml-s fixed a major issue, where you could not use a Mailchimp core function, the ADDRESS mergefield. 3 1 Link to comment Share on other sites More sharing options...
Marco Ro Posted November 12, 2018 Share Posted November 12, 2018 How can I use this moule for all users who are saved with a specific category? I'm not sure which Class and method need to use and also maybe I not get the correct fields. wire()->addHookAfter('Pages::saved', function($event) { $page = $event->arguments(0); if($page->template == "user"){ if ($user->hasRole('login-facebook')) { $mc = $modules->get("SubscribeToMailchimp"); $email = $page->email; $subscriber = [ 'FNAME' => $page->pad_firstname, 'MMERGE4' => $page->$country_title, ]; $mc->subscribe($email, $subscriber); } } }); Link to comment Share on other sites More sharing options...
daniels Posted November 12, 2018 Author Share Posted November 12, 2018 Hey @MarcoPLY , not sure if I get it right, but do you want to add user to specific categories? In the API naming, groups are called 'interests'. You can add them as additional parameters as in the example below. To get the interest IDs is a little pain-in-the-ass but I'll try to guide you: 1. Go to https://api.mailchimp.com/playground/ and enter your API key. 2. Click on 'Lists' and choose 'interest-categories' from the 'Subcategories' of your related list. 3. Choose 'interest' from 'Subcategories' of your related interest category 4. Now you can click on each interest and you'll get the id which should be the ID that you have to use in the 'interests' part of the example below. Please let me know if this works for you! When I find some time, I'll add a way to get these ids in the module Settings in PW admin. Example from the docs: // Work with additional parameters (not merge_field values!) $mc->subscribe('john.doe@example.com', NULL, NULL, [ 'language' => 'en', // find language list here: https://kb.mailchimp.com/lists/manage-contacts/view-and-edit-contact-languages#Language-Codes 'vip' => true, // boolean vip status 'location' => [ // geo location based on lat/log coordinates 'latitude' => '48.8722344', 'longitude', => '2.7736192' ], 'interests' => [ // subscribe user to interest categories / groups based on group id '32fec3561e' => true, '63mel4395m' => false ] ]); Link to comment Share on other sites More sharing options...
daniels Posted November 12, 2018 Author Share Posted November 12, 2018 Ok @MarcoPLY , I think I got your question completely wrong ? I leave my reply anyway if someone needs it one day... Have you tried to var_dump the subscriber? What do you get there? Is the $ before country_title intentional? 1 Link to comment Share on other sites More sharing options...
Marco Ro Posted November 12, 2018 Share Posted November 12, 2018 Hi @daniels, thank you for your reapply! eheh, yes you have right. I explain better what I have to do In addition to the loginRegister module I also use the registration via Facebook. This registration bypasses the registration form and don't send the data to mailchimp. I thought about making a hook for all the users that are registered, regardless of the method. Then use Pages::saved (I'm not sure it's right) and pass data to mailchimp when the user's page is created. But the attempts I tried don't work, I'm probably wrong the way I access the data. Do you know how can I create this action, to send the data to mailchimp when the users page it's created? (Sorry, I have thought just now that maybe this was a question to put in general) Link to comment Share on other sites More sharing options...
daniels Posted November 12, 2018 Author Share Posted November 12, 2018 No worries ? I suggest testing the subscribe function in a normal doc with test data. If this works (which should :)) try to dump your real data wherever you want to implement the subscription. If you can var_dump the right data there, you should be able to perform the subscription there ? Let me know if you have questions regarding the module itself or run into errors there. 1 Link to comment Share on other sites More sharing options...
Roych Posted November 13, 2018 Share Posted November 13, 2018 Hello, my first time using this module and need some help. I created a new list an setup everything in module settings. But not sure how to create a subscribe form on frontend of my site. Any help is appreciated Thank you R Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now