Skip Navigation

[Resolved] Split: mc4wp (MailChimp for WordPress) – how to access checkbox value using php

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 18 replies, has 2 voices.

Last updated by jayesonE 4 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1871403

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok great

#1873593

Hi Minish
I think I have discovered the problem. The form on the site can update perfectly but when you see the output the format of the submission for the checkboxes with each option value in the array in a new line.
[INTERESTS] => Array
(
[75d797c631] => Array
(
[0] => 57718ea285 // this is output from the form
[1] => a27216269d
[2] => 13b937265f
[3] => 9b9da4f7c7
)

)
But the code you provided displays like:
[interests] => Array
(
[75d797c631] => Array
(
[0] => 57718ea285, a27216269d, 13b937265f, 9b9da4f7c7. // all the versions you suggested print all the options in one line
)

)

How can I get each option on a new line?

#1873757

I was able to create the array properly and match the form version with the following snippet but mailchimp still does not update so I'm pretty well stumped at this point.

add_filter( 'mc4wp_user_sync_subscriber_data', function( \MC4WP_MailChimp_Subscriber $subscriber, \WP_User $user ) {

$list=types_render_usermeta("position-type", array("user_id" => $user->ID,"state"=>"checked"));
$list = explode( ',', $list) ;
$subscriber->merge_fields['INTERESTS']['75d797c631'] = $list;
return $subscriber;

}, 10, 2 );

#1875171

My issue is resolved now. Thank you!