Custom Fields
Re-Envisioned
Support Meta Box Group How to save grouped data?

This topic contains 1 reply, has 1 voice, and was last updated by  SG 8 months, 1 week ago.

  • Creator
    Topic
  • #13689
    Resolved
    SG
    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

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #13691

    SG
    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 1 replies (of 1 total)

You must be logged in to reply to this topic.