<![CDATA[ Mailchimp for MODX - My Forums]]> https://forums.modx.com/thread/?thread=103919 <![CDATA[Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558891
I can't get Sterc's extra to add subscribers to MailChimp lists using FormIt and the MailChimp API to work.

This is the input field I use for the email address:
<input type="text" placeholder="E-mailadres" name="email" id="check" value="[[+fi.email]]" aria-describedby="HelpMyemail" required pattern="email" >

I added a (hidden) field called newsgroup and as described in the documentation, gave it the value "yes".
<input type="hidden" id="newsgroup" name="newsgroup" value="yes" />

The API key in defined in the systems settings.

I call formit with the following scriptproperties:

[[!FormIt?
&hooks=`MailChimpSubscribe,spam,redirect`
&submitVar=`go`
&validationErrorMessage=`something wrong`
&mailchimpListId=`a1c189980c`
&redirectTo=`189`
&validate=`
email:email:required,
newsgroup:required`
]]


When I leave the email address empty, I get an error message from Mailchimp, which indicates - I believe - that I've got the API working. But, when I enter a proper email address, nothing happens. Formit isn't redirecting, Mailchimp isn't giving an error message.

Any idea what might be wrong?

Regards


Ludo
]]>
omegerard Jun 03, 2018, 02:21 PM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558891
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558919 Quote from: andytough at Jun 05, 2018, 07:39 AM
Mailchimp for MODX seems to set the status as 'pending' via the API. This is what makes Mailchimp require the double opt in.

This is set in: mailchimpsubscribe/model/mailchimpsubscribe/mailchimpsubscribe.class.php

I changed the first line in this block of code from 'pending' to 'subscribed' and now my subscriptions do not require a double opt in.

        $subscribeStatus = 'subscribed';
        if ($this->mcSubscribeMode === 'update') {
            $result = $mc->PATCH(
                '/lists/'. $listId . '/members/' . md5($userEmail),
                [
                     'email_address' => $userEmail,
                     'merge_fields'  => [
                         $this->mcFieldName    => $userName,
                         $this->mcFieldLName    => $userLName,                       
                         $this->mcFieldCompany => $company
                     ],
                     'status' => $subscribeStatus
                ]
            );
        } else {
            $result = $mc->post(
                '/lists/'. $listId . '/members',
                [
                    'email_address' => $userEmail,
                    'merge_fields'  => [
                        $this->mcFieldName    => $userName,
                         $this->mcFieldLName    => $userLName,                       
                        $this->mcFieldCompany => $company
                    ],
                    'status' => $subscribeStatus
                ]
            );
        }


I have not encountered any problems as a result of doing this, but I can't guarantee that it is not going to cause some unforeseen issue!

Great tip! Thank you very much.

Ludo
]]>
omegerard Jun 05, 2018, 09:20 AM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558919
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558918 Mailchimp for MODX seems to set the status as 'pending' via the API. This is what makes Mailchimp require the double opt in.

This is set in: mailchimpsubscribe/model/mailchimpsubscribe/mailchimpsubscribe.class.php

I changed the first line in this block of code from 'pending' to 'subscribed' and now my subscriptions do not require a double opt in.

        $subscribeStatus = 'subscribed';
        if ($this->mcSubscribeMode === 'update') {
            $result = $mc->PATCH(
                '/lists/'. $listId . '/members/' . md5($userEmail),
                [
                     'email_address' => $userEmail,
                     'merge_fields'  => [
                         $this->mcFieldName    => $userName,
                         $this->mcFieldLName    => $userLName,                       
                         $this->mcFieldCompany => $company
                     ],
                     'status' => $subscribeStatus
                ]
            );
        } else {
            $result = $mc->post(
                '/lists/'. $listId . '/members',
                [
                    'email_address' => $userEmail,
                    'merge_fields'  => [
                        $this->mcFieldName    => $userName,
                         $this->mcFieldLName    => $userLName,                       
                        $this->mcFieldCompany => $company
                    ],
                    'status' => $subscribeStatus
                ]
            );
        }


I have not encountered any problems as a result of doing this, but I can't guarantee that it is not going to cause some unforeseen issue!]]>
andytough Jun 05, 2018, 07:39 AM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558918
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558900 Quote from: nuan88 at Jun 03, 2018, 09:21 PM
Ok good you got it working, what was the problem if you don't mind.

I just hoped maybe i got lucky lol

I removed all the other fields in the form. And then I tried it again and discovered the reditect was working. Then I checked my email to find an email from Mailchimp with the request to confirm the subscription. I did check the Form Settings to be sure: no, I had not marked the 'Enable double opt-in" feature. Can anybody confirm that Mailchimp enforces double opt-in if you use the API?

Ludo
]]>
omegerard Jun 04, 2018, 03:46 AM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558900
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558897
I just hoped maybe i got lucky lol]]>
nuan88 Jun 03, 2018, 09:21 PM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558897
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558896 Quote from: nuan88 at Jun 03, 2018, 06:52 PM
name="email" id="check"


This looks highly suspicious to me. the names and ids and so on are always the same for a value. every other value in that string is "email", where did that "check" come from?

I could be totally off base but it looks weird

It might be weird, but I think it's not the problem.

I managed to make it work, but it looks like Mailchimp always wants the subscriber to confirm the subscription via email even if you haven't checked the "Enable double opt-in" checkbox in the Form Settings.

Ludo]]>
omegerard Jun 03, 2018, 08:27 PM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558896
<![CDATA[Re: Mailchimp for MODX]]> https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558892
name="email" id="check"


This looks highly suspicious to me. the names and ids and so on are always the same for a value. every other value in that string is "email", where did that "check" come from?

I could be totally off base but it looks weird]]>
nuan88 Jun 03, 2018, 06:52 PM https://forums.modx.com/thread/103919/mailchimp-for-modx#dis-post-558892