Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF7 checkbox is passed as array instead of URL #452

Open
arnelap opened this issue Jul 1, 2017 · 1 comment
Open

CF7 checkbox is passed as array instead of URL #452

arnelap opened this issue Jul 1, 2017 · 1 comment
Labels

Comments

@arnelap
Copy link
Contributor

arnelap commented Jul 1, 2017

Here’s a var_dump of the $data variable from the mc4wp_integration_contact-form-7_data hook:

array(4) {
["FNAME"]=>
string(5) "First"
["LNAME"]=>
string(4) "Last"
["EMAIL"]=>
string(14) "test@xxxxx.com"
["CHECKBOX1"]=>
array(1) {
[0]=>
string(4) "opt1"
}
}

And:

ERROR: Contact Form 7 > MailChimp API Error: Bad Request. The resource submitted could not be validated.

  • merge_fields.CHECKBOX1 : Data did not match any of the schemas described in anyOf.

Please notify: https://wordpress.org/support/topic/sending-cf7-checkbox-fields-to-a-mailchimp-list/

@arnelap
Copy link
Contributor Author

arnelap commented Jul 10, 2017

MailChimp doesn't really allow checkboxes (multiple values for 1 field).

You can use this filter to "join" the data in the array and send it in on 1 line.

add_filter( 'mc4wp_integration_contact-form-7_data', function( $data ) {
   $data['CHECKBOX1'] = join( ';', $data['CHECKBOX1'] );
   return $data;
});

Of course similar technique is possible to set the field in MailChimp to anything else you like based on the data your checkbox returns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants