Comments

rcaracaus’s picture

this doesn't work for me.. subscribe.. I need this to work for D7

dddbbb’s picture

I'd love to see this working for D7 too.

damienmckenna’s picture

Will see if myself or cweagans can get to this in the next week or two, a client of ours needs it.

TimelessDomain’s picture

Title: Drupal 7 patch » Drupal 7 Port of Webform Mailchimp
Status: Patch (to be ported) » Needs review
Issue tags: +drupal 7 port, +d7 ports
rcaracaus’s picture

Assigned: Unassigned » achandel
Status: Needs work » Needs review

I ran the patch with the windows git application and it doesn't send to mailchimp.

carn1x’s picture

subscribe

achandel’s picture

I have been using this module (after the patch) for some time. You can check it our here http://www.sensegrow.com. It has been working fine. It also sending the names etc. Please let me know if i can help anyone further with utilizing this module on Drupal 7.

achandel’s picture

Component: Code » Miscellaneous
Priority: Normal » Critical
StatusFileSize
new11.41 KB

I have upgraded the module to work with the following now:
MailChimp 7.x-2.1
Webform 7.x-3.13
Please find the new module attached. I have tested it and it is working fine. You can try this with latest version of Mailchimp and Webform module. Please let me know if there are issues in this release. I am not able to produce patch (some problem with my git installation). So i have attached the ZIP. Someone please upload the patch on my behalf.

steven1310-1’s picture

Project: Webform Mailchimp » Mailchimp
Version: 6.x-1.x-dev » 7.x-2.1
Component: Miscellaneous » Lists

Hi achandel,
thanks for the module you posted.
But somehow I'm not getting it to work. Maybe I'm doing something wrong.

I think I made all the right settings.

I have created the webform field and it posts the data.
I have added the list from mailchimp to the webform field.
But the poster of the form is not added to the mailchimp mailing list that I provided.

Is there something I missed?

Thanks again.

Pedro Lozano’s picture

Project: Mailchimp » Webform Mailchimp
Version: 7.x-2.1 » 6.x-1.x-dev
Component: Lists » Code
Assigned: achandel » Unassigned
Priority: Critical » Normal
Status: Needs review » Active

Moving back to Webform Mailchimp project so people don't create duplicate issues there.

Pedro Lozano’s picture

Status: Active » Needs work
StatusFileSize
new17.05 KB

Fixed the patch on the other issue.

I still have to look if @achandel's version has any improvement.

Left as needs works because there are still some things unported, but the subscriptions work.

Pedro Lozano’s picture

StatusFileSize
new10.36 KB

Wrong patch in the previous comment.

lsolesen’s picture

What is the status of this. Do you need us to do anything?

blackdog’s picture

Patch does not apply.

Pedro Lozano’s picture

StatusFileSize
new10.56 KB

@backlog the patch must be applied on 6.x-1.x with patch -p1

I did a reroll for your last commit and made some fixes.

blackdog’s picture

I can't get it to apply with either git apply or patch - p1.

But, reading the patch, this needs cleaning up:

   // Fetches existing components, checks if any of them are e-mail fields.
@@ -185,26 +181,33 @@ function _webform_render_mailchimp($component, $value = NULL, $filter = TRUE) {
   }
 
   $element = array(
-    '#title'             => htmlspecialchars($component['name'], ENT_QUOTES),
+    //'#type'              => 'mailchimp',
+    '#title'             => $filter ? _webform_filter_xss($component['name']) : $component['name'],
     '#title_display'     => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
+    //'#default_value'     => $filter ? _webform_filter_values($component['value'], NULL, NULL, NULL, FALSE) : $component['value'],    
     '#required'          => $component['mandatory'],
     '#weight'            => $component['weight'],
-    '#prefix'            => '<div class="webform-component-'. $component['type'] .'" id="webform-component-'. $component['form_key'] .'">',
-    '#suffix'            => '</div>',
+    //'#prefix'            => '<div class="webform-component-'. $component['type'] .'" id="webform-component-'. $component['form_key'] .'">',
+    //'#suffix'            => '</div>',
+    //'#field_prefix'      => empty($component['extra']['field_prefix']) ? NULL : ($filter ? _webform_filter_xss($component['extra']['field_prefix']) : $component['extra']['field_prefix']),
+    //'#field_suffix'      => empty($component['extra']['field_suffix']) ? NULL : ($filter ? _webform_filter_xss($component['extra']['field_suffix']) : $component['extra']['field_suffix']),
+    '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],    
+    '#attributes' => $component['extra']['attributes'],
+    //'#theme_wrappers' => array('webform_element'),
     '#webform_component' => $component,
-    '#theme'             => 'webform_mailchimp_email',
-    '#pre_render'        => array('webform_element_title_display'),
-    '#element_validate'  => array('_webform_validate_mailchimp_email'),
+    //'#theme'             => 'webform_mailchimp_email',
+    //'#pre_render'        => array('webform_element_title_display'),
+    //'#element_validate'  => array('_webform_validate_mailchimp_email'),
   );
basicmagic.net’s picture

subscribe

dddbbb’s picture

@basicmagic.net

Stop subscribing, start following: http://drupal.org/node/1306444

rcaracaus’s picture

Assigned: achandel » Unassigned
Status: Needs review » Needs work

It is really frustrating that none of your modules work. I tried to debug them. No success. I tried the last patch 1094226-webform-mailchimp-d7-5.patch and it looked like it should of worked but wasnt subscribing the user.

Mattias Holmqvist’s picture

Seems like I have the same problem as rcaracaus.
However I used http://drupal.org/files/webform_mailchimp.zip linked to by achandel (#8).

The module seems to work as intended in Drupal.
I can choose a mailing list from my Mailchimp account to be used with the webform checkbox.

But the subscription is not accepted by Mailchimp for some reason.
All I can see is "1 New Subscribers" on Mailchimp's Dashboard page after submitting the webform. When I click on that email address I come to a 404 page and I still have 0 subscribers in my Mailchimp mailing list.

rcaracaus’s picture

StatusFileSize
new10.52 KB

I am fairly new to GIT and I wasn't applying the patch properly. This page was very helpful to get started. http://drupal.org/project/webform_mailchimp/git-instructions Now that I understand the process in patching etc I think I will be able to contribute much more. With these instructions I finally got the patch working from comment #15. You need to git clone the 6.x-1.x branch then apply the patch with 'git apply'

After playing for a long while and isolating the function that does the heavy lifting I was able to finally get my emails sending over to mailchimp. When this happened I knew I would be able to do whatever I needed.. eventually. Here is the important function:

mailchimp_subscribe_user($lists[$mailchimp_list], $email_address, $mergefields_replacements, TRUE, NULL);

But in order for this to work you need to feed it an ENTITY. The mailchimp module is weird.. if you sift through the code there is a $list array and a $list entity.

This function wasn't returning any array for me, that is why it dodn't submit:

$lists = _mailchimp_get_available_lists($user);

Maybe there was something going on when I was logged in or something. Not sure.

I changed that line to load the entity a different way:

$lists = entity_load('mailchimp_list', $list, $conditions, $reset);

This will only interact with one mailchimp list FYI.

ALSO: You want to make sure the mailchimp_lists module is installed and that a list is created. This module should come with a readme file. I will write it if I end up figuring a little more out how this module works.

P.S. This module works GREAT when you get it working. The mergetag and interest functionality lets me do pretty much everything I need.

lsolesen’s picture

Could you write up some docs on how the interst fields work.

rcaracaus’s picture

You need to create a Group with some subgroups in your Mailchimp account. Then you need to make a select field and map it to be the same name. I would use groups with one word.. not sure if spaces are handled properly. Check your Watchdog table for debugging.. or you can die the error directly in the mailchimp_subscribe_user function for testing.

arcanumxiii@gmail.com’s picture

Should be nice and all, but it seem some parameter are wreaking havoc : $conditions and $reset at line 132.
Now I know they are use by entity_load — i've tried with an empty array for conditions since it's deprecated, and a false for reset, but to no avail.

I would gladly accept some help on the matters.

lsolesen’s picture

What is the status for getting an alpha release for the 7.x module on its way?

lsolesen’s picture

Status: Needs work » Needs review
StatusFileSize
new17.34 KB

Here is a patch that actually subscribes the user to the lists - and added a bunch of watchdog statements for debugging.

tabestan’s picture

I tried to apply the patch using http://drupal.org/project/webform_mailchimp/git-instructions and got the following error:

my@localhost:~/patches/webform_mailchimp$ git pull origin 6.x-1.x
From http://git.drupal.org/project/webform_mailchimp
 * branch            6.x-1.x    -> FETCH_HEAD
Already up-to-date.
my@localhos:~/patches/webform_mailchimp$ git apply -v portd7-1094226-26.patch
portd7-1094226-26.patch:19: trailing whitespace.
      'field_suffix' => '',      
portd7-1094226-26.patch:24: trailing whitespace.
      'private' => FALSE,      
portd7-1094226-26.patch:135: trailing whitespace.
    //'#default_value'     => $filter ? _webform_filter_values($component['value'], NULL, NULL, NULL, FALSE) : $component['value'],    
portd7-1094226-26.patch:144: trailing whitespace.
    '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],    
portd7-1094226-26.patch:227: trailing whitespace.
  
Checking patch webform_mailchimp.inc...
error: while searching for:
    '#description' => t('If using an existing field, make the checkbox checked by default.'),
    '#default_value' => !empty($component['extra']['checkbox_checked_by_default']) ? $component['extra']['checkbox_checked_by_default'] : 0,
    '#weight' => 3,
    '#suffix' => '</div>',
  );

  return $form;
}


error: patch failed: webform_mailchimp.inc:128
error: webform_mailchimp.inc: patch does not apply
Checking patch webform_mailchimp.info...
Checking patch webform_mailchimp.module...
error: while searching for:
        // Need to know if we should look for our own email field or another.
        if ($field['extra']['use_existing_email_field'] != 'mailchimp_field') {
          // If using existing field, check if the checkbox was checked
          if ($submission->data[$key]['value']['mailchimp_signup'] == 1) {
            // Loop through components again to find our email field
            foreach($node->webform['components'] AS $key2 => $field2) {
              if ($field2['form_key'] == $field['extra']['use_existing_email_field']) {

error: patch failed: webform_mailchimp.module:37
error: webform_mailchimp.module: patch does not apply
lsolesen’s picture

applies to master not 6x

tabestan’s picture

Thanks, it did the trick.

To add the component, I added an email field to my webform and choose that field as default. Small typo (subsribe instead of subscribe).

jnettik’s picture

So with the above patches is there a 7.x release on the horizon?

jnettik’s picture

Status: Needs review » Reviewed & tested by the community

I just tested the patch out on a site I'm working on and it seemed to work for me. Though I there still is the above mentioned typo ;)

blackdog’s picture

Status: Reviewed & tested by the community » Fixed

Ok, I've committed a functioning patch, based on the work in this issue. Thanks everyone!
It still needs a lot of testing. I'll create a dev-release which should be up soon.

jnettik’s picture

So I've actually stumbled upon a couple small notices while working on things. The first two occur when you submit a form that has an email field and the MailChimp field is tied to that email field, but you don't actually click the "Subscribe" checkbox for MailChimp. Basically in my use, I have a contact form where you can opt to sign up for the newsletter and if you do, it should use the email address field you provide in the form.

All I think we need is a check on the MailChimp field that will only run the code referenced if that checkbox is checked.

Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert() (line 151 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.module).
Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert() (line 125 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.module).

In light of the above notices, I opted to go with the option of having MailChimp field create the email field for me. I got the second notice below:

Notice: Undefined variable: size in _webform_render_mailchimp() (line 210 of /sites/all/modules/custom/webform_mailchimp/webform_mailchimp.inc).

Easy enough to fix, just commented out line 211 defining the size of the text field.

Edit: Moved this over to it's own issue so as not to open up this one again. New issue is at #1415798: Notice: Undefined variable: email_address in webform_mailchimp_webform_submission_insert().

Status: Fixed » Closed (fixed)
Issue tags: -drupal 7 port, -d7 ports, -mailchimp webform drupal 7

Automatically closed -- issue fixed for 2 weeks with no activity.