Plugin Contributor
Lap
(@lapzor)
Hi Tui,
The problem with Grafity forms in this regards is that it generates field names sort of randomly, such as name=”input_4″ so it’s hard for MC4WP to know what field is what.
The only way to do it is if you manually map those field names (you can get them via “right click > inspect” when you view the form) to the correct MailChimp fields with some custom code.
add_filter( 'mc4wp_integration_gravity-forms_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber ) {
$subscriber->merge_fields[ "FNAME" ] = sanitize_text_field( $_POST['input_2'] );
$subscriber->merge_fields[ "COUNTRY" ] = sanitize_text_field( $_POST['input_4'] );
return $subscriber;
});
This example would map input_2 to FNAME and input_4 to the MailChimp field COUNTRY.
Hope that helps. If you have any questions, please let me know!
Hi!
Perfect, it works.
One last question, how about the city field?
I have tried:
$subscriber->merge_fields[ “ADDRESS” ][“city”] = sanitize_text_field( $_POST[‘input_17’] );
and
$subscriber->merge_fields[“CITY”] = sanitize_text_field( $_POST[‘input_17’] );
And didn’t work.
Best regards,
Rui Parente
Plugin Contributor
Lap
(@lapzor)
I recommend not using fields of the type “address” in MailChimp as they have a pretty strict validation on that field. If you want that to work you need to send in a whole complete address, not just the city, and it all needs to be valid.
I recommend using a normal text field instead.
Hope that helps. If you have any questions, please let me know!