Change field ID numbers to FNAME/LNAME
-
I am trying to link Wp Forms with MC. It works with CF7 but I want to change form plugins. However, new submissions don’t record the submission in my MC List. How do I change the field name to FNAME and LNAME?
The page I need help with: [log in to see the link]
-
Did you already add the “Mailchimp” field to the WP form?
That should at least add their email to Mailchimp.For the field mapping, if it isn’t working automatically you can manually map the fields:
https://github.com/ibericode/mc4wp-snippets/blob/master/integrations/wp-forms-field-mapping.phpYou will have to look in the html source code of the form to find the field names and map them manually with a code snippet.
Hope that helps. If you have any questions, please let me know!
I have added the checkbox and even that doesn’t add the email address. I want to try this code you suggested. I have a few different forms where the field ID is different each time. How do I specify the form id?
You should first look into getting the emails added.
Anything in the log on MC4WP > Other?You can get the from ID from the post value: wpforms[id]
It’s only logging when the address already exists. When the address… there is no log. Even when I submit the form with the new email 2 or 3 times
What I mean is, where in this code do I put the form id?
<?php // The problem with WPForms forms in this regard is that it generates field names that aren't always easy for our plugin to recognize. // You will have to inspect the source of the form to find field names (name="...") for each field and manually map them as such: add_filter( 'mc4wp_integration_wpforms_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber ) { $subscriber->merge_fields[ "FNAME" ] = sanitize_text_field( $_POST['wpforms[fields][7][first]'] ); $subscriber->merge_fields[ "COUNTRY" ] = sanitize_text_field( $_POST['wpforms[fields][7][country]'] ); return $subscriber; });
I changed the log to capture everything and it says it was successful… but it doesn’t add it to the list
[2022-10-10 14:23:18] INFO: WPForms > Successfully subscribed info@ma*******.co.za
[2022-10-10 14:24:08] INFO: WPForms > Successfully subscribed info@ma*******.co.zaOk, that means that it’s really working as it should. You should have received an opt-in email. Only after confirming the opt-in the email will show in your Mailchimp audience.
For form ID recognition the code would look like this:
<?php // The problem with WPForms forms in this regard is that it generates field names that aren't always easy for our plugin to recognize. // You will have to inspect the source of the form to find field names (name="...") for each field and manually map them as such: add_filter( 'mc4wp_integration_wpforms_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber ) { if($_POST['wpforms[id]'] == "1234") { $subscriber->merge_fields[ "FNAME" ] = sanitize_text_field( $_POST['wpforms[fields][7][first]'] ); $subscriber->merge_fields[ "COUNTRY" ] = sanitize_text_field( $_POST['wpforms[fields][7][country]'] ); } if($_POST['wpforms[id]'] == "5678") { $subscriber->merge_fields[ "FNAME" ] = sanitize_text_field( $_POST['wpforms[fields][8][first]'] ); $subscriber->merge_fields[ "COUNTRY" ] = sanitize_text_field( $_POST['wpforms[fields][8][country]'] ); } return $subscriber; });
There is no double opt in option in the field settings for the Mailchimp field.
Yes you’re right. Actually WpForms integration doesn’t have that option and is always double opt-in. Sorry about that.
Maybe you can ask your hosting provider if they can explain these marked linesin the log file to you:
I dont understand. So it wont add the person until they double opt-in? Is there no way to remove that?
Indeed. With double opt-in turned on it won’t show the contact until the opt0in is confirmed, With the WpForms integration there is no way to remove that.
Thank you for helping me figure that out.
I might be pushing my luck, but do you by any chance know where to change the circled text in this image? https://imgur.com/JPbkKp6
It’s the heading name in the double opt-in that the client gets
In the audience settings I guess? Would be better to ask Mailchimp support as it’s noting to do with our plugin.
- The topic ‘Change field ID numbers to FNAME/LNAME’ is closed to new replies.