Closed (won't fix)
Project:
Mailchimp
Version:
6.x-2.x-dev
Component:
Lists
Priority:
Major
Category:
Feature request
Assigned:
Reporter:
Created:
12 Oct 2011 at 13:17 UTC
Updated:
28 Jun 2016 at 16:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
strategictech commentedI'm going to give this a whirl.
Comment #2
essbee commentedCool. Happy to do testing on this.
I tried to subscribe via Rules using "Execute custom php" but couldnt get it to fire.
Look forward to seeing where you get with it.
Cheers,
Sam
Comment #3
essbee commentedJust realised you will be working on D6 - I'll take a look at what you come up with an look to port it to D7.
Comment #4
strategictech commentedVersion .001 complete not perfected but since there is some momentum I'm posting the working code thanks for taking interest. I tend to cut corners so feel free to be as critical as you want. I'm happy to make changes and will not be offended.
Also, the mailchimp module was not working on my machine (windows xampp) I posted a workaround here: http://drupal.org/node/1388722
***** If you do not use the workaround above (mailchimp works out of the box) ******
Modify lines 43 & 67 as follows:
foreach($all->data as $list_info)*****
Intallation:
Add the attached file to the [Drupal]/sites/*/modules/mailchimp directory.
Enable Rules module (* if rules is enabled you will probably need to go to admin>build>modules and click the "Save configuration" button.)
V.001 features:
Actions:
- Add user to list (aka subscribe to list)
- rule action form displays dropdown of all lists.
- Remove user from list (aka unsubscribe from list)
- rule action form displays dropdown of all lists.
There are no changes to the other module files (except the workaround mentioned above). Anyway I'm looking forward to getting some feedback and I will be working to further enhance this to include conditions and possibly events if their is a desire.
Comment #5
essbee commentedCheers strategictech, I'll have a play later on.
Looking through the code all looks good for a first pass.
Here are a couple of thoughts.
I think the biggest thing is going to be how to populate custom mailchimp fields with data. If you have any of those fields set to required the subscribe will fail.
I believe the list array includes the field information, their type, and whether they are required, I guess it would be a matter of looping through the fields and adding them to the action form so the rule can create a merge_vars array - this would allow the end user to either provide a default value or use tokens.
Also I think it would be worth adding a checkbox for the send_welcome variable and using the double_optin variable taken from the existing mailchimp module settings rather than hard coding.
Cheers,
Sam
Comment #6
strategictech commentedSam, thanks for the remarks. I'll work on the custom mailchimp fields next.
Comment #7
strategictech commentedAfter playing around with merge vars array it seems like the best way to handle this would be to use the same settings as the MailChimp Subscription Lists form. I believe this will make the overall integration between MailChimp and the integrated Drupal site more consistent.
I'm interested to hear if anyone else has an opinion on using this approach.
I have this working now, but will move forward with the send_welcome and double_optin values before I re-post however here is the relevant code:
@line: 34
Comment #8
essbee commentedWould this mean there is no option to insert tokens into the fields?
Comment #9
strategictech commentedNo, the default settings page populates a list of all the available tokens for each Merge Variable. It simply means that the add user action uses the same Drupal variables as those set on the MailChimp settings page.
The other way to do this would essentially override the default mapping of Mailchimp Merge Variables to Drupal data. I realize it is nice to have lots of options but I really do not see much value in being able to set this in two places. I could be convinced otherwise; let me know what you think.
Comment #10
essbee commentedThe problem with using the default mappings would be they may not be available.
Ahh right I see what you mean. I agree that makes sense.
Comment #11
strategictech commentedAlright, I've tested this with the most recent 6.x version of mailchimp and it works without a hitch.
I am attaching the mailchimp.rules.inc that will work "out of the box".
This version adds two actions:
- Add user to a list
- Remove user from a list
Both actions use the same settings for Merge Vars as the default settings on the admin/settings/mailchimp page.
I think this most basic functionality is ready for testing and inclusion in at least the dev, if not the main 6.x release of the MailChimp Module.
Any information on how to make this happen would be greatly appreciated.
I will continue working on other features and will continue to respond to any feedback posted here.
Comment #12
strategictech commentedComment #13
agileware commentedsubscribing
Comment #14
Offlein commentedStrategicTech, we've got the same needs - I'm going to have some developers on this to attempt to add "Send a campaign" functionality if possible. We'll otherwise be testing your implementation over the next couple weeks. Thank you!
Comment #15
strategictech commentedGreat let me know if you have any issues.
Comment #16
designerbrent commentedWould love to see this, especially for Drupal 7.
Comment #17
fagoI've rolled a patch for D7, see #1593224: provide rules integration for 7.x-2.x
Comment #18
tinker commentedThx @strategictech for your work. This is a very useful feature. I have changed all $q calls to use mailchimps built in _mailchimp_get_api_object() and cleaned up code format. All tested and works great.
Comment #19
strategictech commentedAwesome! I'm looking forward to seeing my first contribution added to a contrib module.
Comment #20
tinker commentedHave been using inc from #18 for almost a year on 3 sites and it has not failed to work. Any chance of a commit? This does not hurt anything and opens many possibilities.
Comment #21
tinker commentedProviding a patch in the hopes that this will get committed. Not changed from #18.
Apply patch with
git am mailchimp-rules-integration-1307222-21.patchComment #22
nrackleff commented“And now our watch [for support of the 6.x version of the MailChimp module] has ended…” With the end of Drupal 6 support, I’m sad to say we too must turn the page.
Fret not! The 7.x-4.x and 8.x versions come highly recommended. Both are using Mailchimp’s new API 3.0 and are being actively maintained. “What is dead may never die, but rises again, harder and stronger!”