• Resolved gramenauer

    (@gramenauer)


    Hi all!

    Is it possible to add a hidden field inside Contact Form 7 to tell Mailchimp which tag(s) must subscriber be assigned to?

    I want to add the tag “ES” in my mailchimp audience to all users subscribed from a particular form.

    Many thanks in advance!

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    Thanks for reaching out to us.

    To add the subscribers from CF7 to MailChimp with a tag, first please enable that integration and then to add the tag, please modify and add the following PHP code to the “functions.php” file located inside your active theme folder.

    /**
     * This adds the "My tag" tag to all new subscribers added by the plugin.
     *
     * Use "mc4wp_subscriber_form_data" filter only runs for form requests.
     * The "mc4wp_subscriber_data" to hook into both form & integration requests.
     */
    add_filter( 'mc4wp_subscriber_data', function(MC4WP_MailChimp_Subscriber $subscriber) {
       $subscriber->tags[] = 'ES';
       return $subscriber;
    });

    I hope that answers your query. Let us know if you have any further questions.

    Thread Starter gramenauer

    (@gramenauer)

    Hi, Harish

    Thank you very much for your help.

    Using the code you give me, I understand that all CF7 forms I use on the website will send the tag “ES” to mailchimp list, right? Is there any way to select a tag for each form?

    Best,

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Gramenauer,

    You can access the CF7 form ID by using the following code:

    
    add_filter( 'mc4wp_integration_contact-form-7_subscriber_data', function(MC4WP_MailChimp_Subscriber $subscriber, $cf7_form_id) {
       if ($cf7_form_id == 500) {
           $subscriber->tags[] = 'ES';
       } else if ($cf7_form_id == 510) {
           $subscriber->tags[] = 'NL';
       }
       return $subscriber;
    }, 10, 2);
    

    That way you can set a different tag based on the form ID that was used to trigger the hook.

    Hope that helps!

    Thread Starter gramenauer

    (@gramenauer)

    Thanks a lot!

    Thread Starter gramenauer

    (@gramenauer)

    Just another issue. The mc4wp-checkbox text is not translated on English version (https://www.thefatfinger.com/home/#contact), although I translated it on mailchimp-for-wp string. How could I fix it?

    Thanks again in advance and best regards!

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    @gramenauer,

    Below is the code used when you add our shortcode for CF7. If you want to translate it to different language, then you can use the following code instead of using the shortcode.

    <p><!-- Mailchimp for WordPress v4.5.3 - https://mc4wp.com/ --><input type="hidden" name="_mc4wp_subscribe_contact-form-7" value="0"><span class="mc4wp-checkbox mc4wp-checkbox-contact-form-7"><label><input type="checkbox" name="_mc4wp_subscribe_contact-form-7" value="1"><span>?Suscríbeme a la lista de correo!</span></label></span><!-- / Mailchimp for WordPress --></p>

    Hello!
    I also want to add that code for Contact form 7, to send the tags to Mailchimp account. I have CF7 plugin installed, and have Mailchimp account, what other plugins are needed to make this code work? Thank you

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    You will need CF7 and our plugin installed correctly.

    Hi!

    Is it possible to add or update multiple tag(s)?

    Many thanks in advance!

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @democoder3535,

    We would request you to create a new topic.

    Hello!

    I wanted to know if there is a way to add a tag to a contact if a checkbox is checked.

    i tried doing it like this but it didn’t work, only TAG1 is assigned.

    
    if($cf7_form_id == 1)
        {
            $subscriber->tags[] = 'TAG1';
    
            if(isset($_POST['mc4wp_checkbox']) && $_POST['mc4wp_checkbox'] == 1)
            {
                $subscriber->tags[] = 'TAG2';
            }
        }
    

    Thanks!

    Plugin Contributor Lap

    (@lapzor)

    Hi,

    I don’t have a code snippet for that.
    I have one for a different tag per form:
    https://github.com/ibericode/mc4wp-snippets/blob/master/integrations/contact-form-7/different-tag.php

    Maybe you can edit that snippet to do what you need, but I’ve not been able to test that yet.

    Hope that helps. If you have any questions, please let me know!

    Hi,

    I don’t undestand why this not work.

    
    add_filter( 'mc4wp_integration_contact-form-7_subscriber_data', function(MC4WP_MailChimp_Subscriber $subscriber, $cf7_form_id) {
        if ($cf7_form_id == '718') {
            $subscriber->tags[] = 'Contacto';
        } else if ($cf7_form_id == '1442') {
            $subscriber->tags[] = 'Newsletter';
        }
        return $subscriber;
    }, 10, 2);

    and i try too this:

    add_filter( 'mc4wp_integration_contact-form-7_subscriber_data', function(MC4WP_MailChimp_Subscriber $subscriber, $cf7_form_id) {
        if ($cf7_form_id == 718) {
            $subscriber->tags[] = 'Contacto';
        } else if ($cf7_form_id == 1442) {
            $subscriber->tags[] = 'Newsletter';
        }
        return $subscriber;
    }, 10, 2);

    ?Can anyone help me?

    Thanks

    • This reply was modified 4 years, 5 months ago by fpak.
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @fpaneke,

    Please note that the tags can only be added to new subscribers. If the user already exists in MailChimp, then the tags would not be added or updated.

    When testing, please test using a new email address that is not in your Mailchimp Audience/List and let us know if that works.

    Hey @hchouhan,

    Awesome! That’s this!

    Thanks!!

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Sending tags to mailchimp from contact form 7’ is closed to new replies.