Skip Navigation

[Resolved] Checkbox fields using WP-All-import addon

This support ticket is created 3 years, 7 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 3 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1810213

Hi guys, I hope this finds you well.

I'm just reaching out regarding importing via spreadsheet to a types created post type that has checkbox fields.

Someone kindly pointed me in the general direction of the BETA WP-All Import Types extension which is great. The only thing I'm now left struggling with is getting Checkbox data imported.

I have tried everything I can think of including exporting one of the entries, dumping what is stored in the checkbox field (which looks like the below) and I can't get anything to stick and it consistently gives the wrong items selected.

If anyone has any idea of how I can get my client checkbox data in to the system, at this point I would be incredibly grateful as manually adding all of the entries would quite literally take weeks ! (just to add, I honestly don't mind if I have to add it serialised or similar just any way for me to get the info in would be tremendous !!)

Many thanks

G

Example of field dump:

a:18:{s:64:"wpcf-fields-checkboxes-option-29ea4df1a43813f266e5a67fb2f1937e-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-98dfdb960a70991a908c3cc80156d10c-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-ad105a400a44b113f3054cfc7da32197-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-67bc0c95b97366dfb4fcc0e4c2d90c72-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-b295c185f1b98b8ba739a5c6aa7f349b-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-d8a8c59bae5c83dba19b313fc0c706e6-1";
a:1:{i:0;s:1:"8";}s:64:"wpcf-fields-checkboxes-option-4301489a4739847a6981d7757e3bb163-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-f9130def7c2c8e1cc62afa14664e7edd-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-016cdf127155b3de0fcabacc84d38d01-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-a3426fc2d1902a623aad4da9d0423ae9-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-0bc48ca493991c70f48b25fc6c47e70e-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-80c0fdb4e8fa22c952e8bbdee7a7b0ac-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-9f0ddad935bce0a9f00e1d0c5332f1db-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-a5f8d573facd5896802a3bb804c9753d-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-6ffcc9c58a7bd573712615ef64c69b5b-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-0fccdbccb6e3830e6e1380600b1d2943-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-5e0de0d780eb35fcc96c47d3a23632b0-1";
a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-b3dba6bd691d76c2221659efddabfed7-1";
a:1:{i:0;s:2:"99";}}

#1810811

Hello,

It needs custom codes, for example:
Within Toolset Types plugin, there is a PHP function wpcf_admin_fields_get_field(), it can get Types custom checkboxes field setting, including option titles and option values, and construct the field value, and save it into database, see similar thread here:
https://toolset.com/forums/topic/update-checkboxes-checked-state-via-php/#post-235795

#1816295

Hey, thanks so much for this Luo.

So am I right in saying that I would build the php function similar to

 $field = wpcf_admin_fields_get_field('member-category');
$post_id = '12'; //the ID of the post to which to update the custom field
$api_result = array( 'Amateur' );
if (isset($field['data']['options'])){
        $res = array();
    foreach ($field['data']['options'] as $key => $option){
        if (in_array($option['set_value'], $api_result)){
            $res[$key] = $option['set_value'];
        }
    }   
        update_post_meta( $post_id, 'wpcf-member-category' , $res );
}

Which would be added to the WP All Import custom php functions?

I see in the above it's referencing a specific post ID but obviously we need it to create the post on import and we are not targeting categories but am I right in assuming it's roughly the same process for standard custom fields? I.E for example a set of checkboxes added to a post type called "Certificates"?

Again, thank you for your help and support, it's much appreciated !

#1816915

For the question:
Which would be added to the WP All Import custom php functions?

According to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

And it depends on WP All Import plugin, you will need check it with WP All Import support, check if there is any action hook triggered after a post was imported.

For example, if you create a new post in WP admin side, it will trigger the action "save_post", you can use it to trigger you custom PHP codes, more help:
https://developer.wordpress.org/reference/hooks/save_post/

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.