• Resolved DataLife

    (@antibalashifi)


    I need assistance with Mailchimp for WordPress (mc4wp) plugin integration with Contact Form 7

    Dear Mailchimp for WordPress (mc4wp) Support Team,

    Problem Description:
    I have set up a Contact Form 7 form on my website to capture user subscriptions and send the form data to my Mailchimp list using the mc4wp plugin. However, despite the form being submitted successfully, and email/name data successfully being passed to Mailchimp, the custom field (unique-link, in this case) is not being sent to Mailchimp. The custom field data is even being stored in the Flamingo plugin (a Contact Form 7 add-on), but the data is not reaching my Mailchimp list.

    I’ve refreshed the list and made sure the custom field name matches the field name in Mailchimp exactly.

    It may have to do with a quirky interaction of mc4wp with the script I’m running. I say it’s a quirk with mc4wp because again, Flamingo reads the form data just fine.

    1. I have created a custom function to generate a unique link for each subscriber based on their email address. The unique link is generated using a secret key, expiration time, and a hash function. Here’s the code snippet for the link generation (italics = redacted for privacy)
    function generate_secure_link($email) {
      $secret_key = 'mykey';
      $expiration_time = time() + (3 * 24 * 60 * 60); // 3 days from now
      $data = $email . '|' . $expiration_time;
      $hash = hash_hmac('sha256', $data, $secret_key);
      $base_url = "http://mydomain.com/link-validation";
      $link = $base_url . "?data=" . urlencode(base64_encode($data)) . "&hash=" . $hash;
      return $link;
    }

    2. I have created a function to add the generated unique link to the Contact Form 7 form data using the wpcf7_posted_data filter. Here’s the code snippet:

    function add_unique_link_to_cf7_data($posted_data) {
      $email = $posted_data['your-email'];
      $unique_link = generate_secure_link($email);
      $posted_data['unique-link'] = $unique_link;
      return $posted_data;
    }
    add_filter('wpcf7_posted_data', 'add_unique_link_to_cf7_data');

    3. I have created a function to retrieve the unique link value for the Dynamic Text Extension in Contact Form 7. Here’s the code snippet:

    function CF7_get_custom_field($atts) {
      $key = 'unique-link';
      $value = '';
    
      if (isset($_POST[$key])) {
          $value = $_POST[$key];
      }
    
      return $value;
    }

    4. My Contact Form 7 form includes the necessary fields (name and email) and the hidden input field for the unique link. Here’s the form configuration:

    <label> Your Name (required)
        [text* your-name akismet:author autocomplete:name] </label>
    
    <label> Your Email (required)
        [email* your-email akismet:author_email autocomplete:email] </label>
    
    [dynamichidden unique-link "CF7_get_custom_field key='unique-link'"]
    
    [mc4wp_checkbox]
    
    [submit "Subscribe"]
    
    [response]

    The form submissions are successful, and the data is being captured by the Flamingo plugin, but it seems that the integration with mc4wp is not functioning as expected.

    Since the issue appears to be related to the mc4wp plugin integration, I believe your expertise would be more suitable to help resolve this problem.

    Additional Information:

    • WordPress version: 6.5.2
    • Contact Form 7 version: 5.9.3 (updated today)
    • Mailchimp for WordPress (mc4wp) version: 4.9.11 (updated today)
    • PHP version: 7.4.33 (Supports 64bit values)

    FWIW I spent many hours trying to troubleshoot this, so I thank you in advance for your help and support.

    Best regards,
    DataLife

    • This topic was modified 7 months, 4 weeks ago by DataLife.
Viewing 9 replies - 16 through 24 (of 24 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    For a quick test, can you please create a form using our plugin and then share a link?

    Also, please add the final output of below shortcode to our plugin’s form.

    [dynamichidden mc4wp-unique-link “custom_unique_link”]

    This can help us rule out any issue with our integration with CF7.

    Thread Starter DataLife

    (@antibalashifi)

    Thanks for your continued support.

    1. The field doesn’t work with that formatting: https://shaina.link/deleteme

    2. Weirdly, even after removing the field, the mc4wp log shows submissions are successful, but *nothing* is showing up in Mailchimp, not even the name/email. I tried this 3 times.

    • This reply was modified 7 months, 3 weeks ago by DataLife.
    • This reply was modified 7 months, 3 weeks ago by DataLife.
    • This reply was modified 7 months, 3 weeks ago by DataLife.
    Thread Starter DataLife

    (@antibalashifi)

    (So the mc4wp form isn’t working even in its default state, oddly.)

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    I did not mean using the shortcode. In the CF7 form, check the source code of the website to copy the final output that is in HTML.

    Also, if MC4WP form is not working, then please go to the “MC4WP > Others” menu and check if you see any errors logged.

    Thread Starter DataLife

    (@antibalashifi)

    Oh, click the link I put in the last post. The top form is CF7.

    Also I’ve been checking the log the whole time, there are no errors.

    • This reply was modified 7 months, 2 weeks ago by DataLife.
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    I tested the MC4WP form and it works. You should find my email “me@har…com” on your list.

    Now, please add the following code to the MC4WP form and let me know so I can test again. Please make sure the name field matches the MC4WP field name.

    <input type="hidden" name="unique-link"  value="http://shainaleis.com/link-validation.php?data=MTcxNDQ0NDY4OA%3D%3D&amp;hash=eae942ebd6795c52867b85c54ee39958b5b1d8e61510a612a544293c467f2ff9">
    Thread Starter DataLife

    (@antibalashifi)

    I see, I had to turn off double-optin on the mc4wp settings and now I can signup.

    I tested the form with the new line you suggested and same thing: name/email are going in, static custom field isn’t.

    Thanks again for your help. Let me know what you want me to try next…

    • This reply was modified 7 months, 2 weeks ago by DataLife.
    • This reply was modified 7 months, 2 weeks ago by DataLife.
    • This reply was modified 7 months, 2 weeks ago by DataLife.
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @antibalashifi,

    Thanks for testing. In this case MC is not recognizing the fields. In the form editing page, do you see the “unique” field displayed? If yes, please click on it to add it to the form and then compare the field name with the one you added manually.

    Thread Starter DataLife

    (@antibalashifi)

    Thanks. I see that when adding it via the button, it uses the MERGETAG instead of the field name. That goes against everything I’ve read about how to use mc4wp over the past two weeks! 🤔

    Anyway I edited the form code you gave me to use the MERGETAG instead, and it works. Then I did the same in CF7 and it works. So we’re good now 🙂

    But, 2 weeks to delete a hyphen. This plugin is great, and it’s free, but that seems like something you (or mailchimp?) might want to fix! Because I did everything according to the guides. Unless I missed something, which is entirely possible.

    • This reply was modified 7 months, 2 weeks ago by DataLife.
Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘CF7 Custom Fields not going to Mailchimp’ is closed to new replies.