Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Evan Herman

    (@eherman24)

    Hi Schaap,

    I would recommend you take a look at our documentation for Contact Form 7 integration where we outline the steps needed to map additional user data to MailChimp:

    https://yikesplugins.com/support/knowledge-base/contact-form-7-populate-the-merge-variable-data-with-additional-information-about-the-user/

    Thanks,
    Evan

    Thread Starter Schaap

    (@schaap)

    Thanks for the link, now I know I have to edit functions.php

    question, is below the right code for 2 fields?

    function additional_contact_form_7_data( $merge_variables, $cf7_data ) {
    $name = $cf7_data[‘your-firstname’];
    $merge_variables = array(
    ‘FIRSTNAME’ => $name,
    );
    return $merge_variables;
    }
    add_filter( ‘yikes-mailchimp-contact-form-7’, ‘additional_contact_form_7_data’, 10, 2 );

    function additional_contact_form_7_data( $merge_variables, $cf7_data ) {
    $name = $cf7_data[‘your-lastname’];
    $merge_variables = array(
    ‘LASTNAME’ => $name,
    );
    return $merge_variables;
    }
    add_filter( ‘yikes-mailchimp-contact-form-7’, ‘additional_contact_form_7_data’, 10, 2 );

    Plugin Author Evan Herman

    (@eherman24)

    No, that does not look to be correct.

    function additional_contact_form_7_data( $merge_variables, $cf7_data ) {
    $first_name = $cf7_data['your-firstname'];
    $last_name = $cf7_data['your-lastname'];
    $merge_variables = array(
       'FIRSTNAME' => $first_name,
       'LASTNAME' => $last_name,
    );
    return $merge_variables;
    }
    add_filter( 'yikes-mailchimp-contact-form-7', 'additional_contact_form_7_data', 10, 2 );

    I don’t know what the name of your contact form 7 fields are, so I can’t provide you with the proper code. From the loops of it, your first name and last name fields are both going to be populated with the same exact values.

    The merge variables is an array, and should be populated using a single function – not multiple – or else it isn’t going to work properly.

    The above code assumes that you have two form fields in MailChimp called ‘FIRSTNAMEandLASTNAME- and that your contact form 7 has 2 fields namedyour-firstnameandyour-lastname`.

    Once those fields are setup, the above code should work properly.

    Thanks,
    Evan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Integration Contact form 7 with Mailchimp’ is closed to new replies.