Add Mailchimp API Key in systemsettings: mailchimpsubscribe.mailchimp_api_key
Create a new single select TV variable and set the input option values to: @EVAL return $modx->runSnippet(‘MailChimpGetLists’);
Add Mailchimp List ID TV in systemsettings: mailchimpsubscribe.list_tv
Add MailChimpSubscribe to your FormIt hooks
Add in your chunk the placeholder fi.error.mailchimp, which holds all Mailchimp error messages.
Add a field called newsgroup, if the value of this field is set to yes, the user will be subscribed to the mailchimp list.
Adding to point 3: I’ve created a Listbox (Single-Select) TV, named it mailChimpList assigned it as requested in the system settings and also assigned it to the resource my subscription form lives on and assigned the wanted list through the resource settings.
I think it might have something to do with the &mailchimpSubscribeField as I admit I don’t understand what that does or what it’s for. The README states:
mailchimpSubscribeField: Field name to use for subscribing users to mailchimp.
mailchimpSubscribeFieldValue: Field value to use for subscribing users to mailchimp.
Seems clear but somehow I don’t get what to do with it.
Overall I can submit the form and even get the success message but it’s not sending me the opt-in email and also there is no email entry in the mailchimp list when I check it there. Any suggestions?
Was trying to get the same extra working and also ran into the Invalid Resource: The resource submitted could not be validated. For field-specific details, see the ‘errors’ array. error.
The plugin does a very poor job of error handling and passing API errors back into view, but with some debugging (read: editing the plugins’ code to dump errors to screen) I finally managed to track down a more useful error:
array(6) {
["type"]=> string(77) "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/"
["title"]=> string(16) "Invalid Resource"
["status"]=> int(400)
["detail"]=> string(98) "The resource submitted could not be validated. For field-specific details, see the 'errors' array."
["instance"]=> string(36) "<..>"
["errors"]=> array(1) {
[0]=> array(2) {
["field"]=> string(12) "merge_fields"
["message"]=> string(36) "This value should be of type object."
}
}
}
That indicates a problem with the merge_fields being sent, which upon further inspection was being passed as empty:
This appears to have been due to the &mailchimpFields property on the FormIt call which only contained the email in my case, just like the code snippet in the opening post here: &mailchimpFields=`email=EMAIL`
After updating that to also include another merge field (&mailchimpFields=`email=EMAIL,name=FNAME` ), the subscribe finally started to work.
Another undocumented thing to note is that the API Key needs to be in the format <key>-<dc> where <dc> is the datacenter, like us2. The API Key I was originally provided was incorrect and missed the DC causing it to not work as well. Again, the plugin does a poor job of communicating such errors, so that takes some digging
Ladies and Gentlemen, I present to you @markh (the h stands for Holmes ) Great work! Thanks alot!
In my case, I simply delivered an empty hidden name field as I’m quite sure you are not allowed to ask for a name with the email for a newsletter due to GDPR.
I didn’t have the issue with the API Key, as I got mine directly from the mailchimp menu where it has the needed format. Still important to know though, as some might get it from a client or otherwise.
Another thing to note is, that you might not need the API Key at all, if you’re entering the mailchimp List ID directly via &mailchimpListId as stated on the extras website:
Option 1: Create a new single select TV variable and set the input option values to: @EVAL return >$modx->runSnippet('MailChimpGetLists');
Add MailChimp List ID TV in systemsettings: mailchimpsubscribe.list_tv
Option 2: Set the FormIt scriptProperty &mailchimpListId to the correct MailChimp List ID
To make this thread complete, here’s my working code:
If there’s an issue with the mailchimpLists TV not showing the Lists in the Resource although everything is setup right, manually clearing the core/cache did it for me.
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.