How to save grouped data?

Support MB Group How to save grouped data?Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13689
    SGSG
    Participant

    I am doing a custom import of CPT by using the PHP API.

    One CTP has a group field, I wonder how to save the serialized value in the meta data.

    I have tried it like this:

    $meta_value = serialize([
                                        [
                                            'active' => 1,
                                            'release_date' => $driverData['date'],
                                            'version' =>; $driverData['version'],
                                            'download_count' => $driverData['counter'],
                                            'file' => [$driverFileAttachmentId],
                                            'os_compat' => $osCompat //is array
                                        ]
                                    ]);
                                    add_post_meta($found_post->ID, 'treiber_group', $meta_value);
    

    The meta box is added like this: https://ghostbin.com/paste/eg26u

    When I try to open the CPT I see:
    Warning: Invalid argument supplied for foreach() in /home/user/public_html/modules/meta-box-aio/extensions/meta-box-group/class-rwmb-group-field.php on line 228

    Warning: Invalid argument supplied for foreach() in /home/user/public_html/modules/meta-box/inc/clone.php on line 28

    #13691
    SGSG
    Participant

    Okay the trick is to not serialize the value when using add_post_meta as it will be serialized through that function.

    Problem is solved.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.