LostKobrakai Posted September 7, 2015 Posted September 7, 2015 I'm currently trying to get a custom fieldtype, which uses InputfieldCheckboxes to work with trackChanges (show changed values as well), but I cannot seem to get it to work. It should just be a simple multiselect of subscribable newsletters, that are loaded from mandrill. Does anybody have any insights on how to tackle that? I need to be able to get the changes, so I can add/remove users from the mailchimp lists accordingly.
LostKobrakai Posted September 7, 2015 Author Posted September 7, 2015 Ok, just notices, that my page field's changes are tracked as well as my custom module's. array(2) { ["subscribed_to"]=> array(1) { [0]=> NULL } ["mailchimp_newsletter"]=> array(1) { [0]=> NULL } } Can I somehow get useful values out of getChanges(true)?
kixe Posted September 8, 2015 Posted September 8, 2015 I am not sure if the following will fit your needs. I wrote a module to subscribe/ unsubscribe from mailchimp using a checkbox in the users template + updating mailchimp if the email address has changed. User profile is provided in frontend. All changings are logged by the module. Here the snippet of the template. function hookAfterSave($event) { $modules = wire('modules'); $user = wire('users')->getCurrentUser(); if ($event->arguments('what') == 'newsletter') { if ($event->arguments('new') == 1) $modules->get('ProcessMailchimp')->subscribe($user->email,false); else $modules->get('ProcessMailchimp')->unsubscribe($user->email); } if ($event->arguments('what') == 'email') { if ($event->arguments('old') != $event->arguments('new') && $user->newsletter) $modules->get('ProcessMailchimp')->update($event->arguments('old'),$event->arguments('new')); } } And the module (running on pw 2.5.29, not tested in 2.6 latest devs)ProcessMailchimp.zip
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