Using Formit for a simple contact form with a message and email input field, I intend to add a simple checkbox for letting my users optionally subscribe to a mailchimp newsletter in addition to sending me a message trough the contact form via formit. I noticed that there is an extra “Mailchimp for modx”. Is it somehow possible to combine this extra with formit to also suscribe to my newsletter only if the checkbox is active but send the formit message anyways or do I have to use Formit and Mailchimp for modx separately?
I hope I am making sense. Upon form submission:
if checkbox “newsletter” is not active, only send message (Formit)
if checkbox “newsletter” is active, send message via formit AND subscribe to mailchimp newsletter (Formit and Mailchimp for modx)
There’s also the Subscribe extra, which puts users into a usergroup. I don’t think it would work with a checkbox, but you could put a link to a custom “subscribe” form, like the “Become a Subscriber” link on this page. The subscribe form is configurable through a Tpl chunk.
Guys, thanks a lot for your input. I will have a look at it and try to make it work with the mailchimpforformit plugin. As bob pointed out, I fear it won’t be working with a simple checkbox but we will see.
Hi dakor2022, did you get this implementation to work? I want to do something similar where I store the form as normal but if a user ticks the subscribe checkbox a fomit hook will also the subscribe the name and email address to a Mailchimp list as per the documentation in mChimpX. If not, how did you do it in the end? Thanks
Hi, I solved it but not by using an existing modx extra. Instead, I wrote my own custom snippet which I inserted into my formit form as a prehook, prior to the execution of the mail hook. Since the website is no longer online, I unfortunately do not have the source code any more. This is what the snippet was basically doing:
checking if the “Subscribe to newsletter” checkbox is checked, if so, continue
gather all data from the form (name, mail, …)
execute a curl request to a mailchimp api endpoint and add the data to your newsletter database
In sum, that really was just about 40 lines of code. Hope it helps.