• Resolved LvPnk

    (@lvpnk)


    Hello,

    I’m trying to map all my form fields to Mailchimp. Currently only the e-mail field is showing up in the submission in Mailchimp. I did some searching in the forums and was able to find some code to start with:

    add_filter( 'mc4wp_integration_gravity-forms_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber ) {
    $subscriber->merge_fields[ "FNAME" ] = sanitize_text_field( $_POST['input_1.3'] );
    $subscriber->merge_fields[ "LNAME" ] = sanitize_text_field( $_POST['input_1.6'] );
    $subscriber->merge_fields[ "ADDRESS" ] = sanitize_text_field( $_POST['input_8'] );
    $subscriber->merge_fields[ "PHONE" ] = sanitize_text_field( $_POST['input_4'] );
    return $subscriber;
    });

    Originally I was using the gravity forms address field but read that it could cause issues and to switch to a regular text field. It looks like now only the phone number is coming through in Mailchimp. Could someone help me with what I could be doing wrong? Thank you.

    The page I need help with: [log in to see the link]

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

    (@hchouhan)

    Hey @lvpnk,

    Can you please go to the “MC4WP > Others” menu, and share with us if there are any errors listed there?

    Also, can you please double check if the “FNAME”, “LNAME” & “ADDRESS” field names in Gravity forms are same as you have included in the code?

    Thread Starter LvPnk

    (@lvpnk)

    Hello, thank you for your reply. I did some more research after seeing the error listed there, “Gravity Forms > Mailchimp API Error: Bad Request. Invalid Resource. Your merge fields were invalid.
    – FNAME : Please enter a value
    – LNAME : Please enter a value
    – ADDRESS : Please enter a value”

    Out of the box gravity forms doesn’t seem to allow the field names to be changed. Is there a way to do this with code?

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @lvpnk,

    That error is because as you are aware, the fields are not sent to MailChimp and you must have set them as “required” fields. You can set them as not required for the time being.

    Regarding the original issue, can you try setting up 2 different text fields for “FNAME” & “LNAME” and then update the custom code to match these field names?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Gravity Forms Mapping Form Fields’ is closed to new replies.