• Resolved pstidsen

    (@pstidsen)


    Hi there,

    I am struggling with these fields: https://pastebin.com/TPLQzTST

    They have worked for several years but now they do not save. I have tried to deactivate all plugins and change to default theme. It still does not work.

    I can select images but after clicking “Update”, they are gone.

    Have you made any change in the plugin?

    Best Regards,
    Peter

    • This topic was modified 2 years, 9 months ago by pstidsen.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi,

    Thanks for getting in touch.

    There is no change in our plugin but I think there are some changes in WooCommerce. To resolve this issue, you can add the prefix before the ID of the meta box and custom fields, like this

    $prefix = 'mb_';
    //Looper igennem farverne og viser en box til hver farve
    foreach($farver as $farve){
        $meta_boxes[] = [
            'title'      => "Tilf?j billeder af " . $farve->name,
            'id'         => $prefix . $farve->slug,
            'post_types' => ['product'],
            'context'    => 'normal',
            'priority'   => 'high',
            'fields'     => [
                [
                    'type'       => 'image_advanced',
                    'id'         => $prefix . $farve->slug,
                    'name'       => 'Tilf?j billeder',
                    'max_status' => false,
                ],
            ],
        ];
    }
    Thread Starter pstidsen

    (@pstidsen)

    Hi Neo,

    Thanks for a quick reply. However, we have thousands of fields with the old ID structure. How do we fix the old fields?

    Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi,

    You can follow this article to know how to change the field ID on your site https://metabox.io/changing-meta-box-field-id/?swcfpc=1

    Thread Starter pstidsen

    (@pstidsen)

    Hi Neo,

    Now I am back from holiday and I have changed the code.
    I am sorry to say that adding a prefix to the ID does not help.

    The new code is here: https://pastebin.com/rRCvjJ4H and it does not work either.

    Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi,

    Hmm, not sure why it does not work on your site. Another way, please change the code to get the post ID with this one

    $post_id = null;
    if ( isset( $_GET['post'] ) ) {
    $post_id = intval( $_GET['post'] );
    } elseif ( isset( $_POST['post_ID'] ) ) {
    $post_id = intval( $_POST['post_ID'] );
    }

    Let me know how it goes.

    Thread Starter pstidsen

    (@pstidsen)

    Wauw… Changing $post_id = false; to $post_id = null; did the trick even though the ID is without prefix. I do not understand how that helped. Do you?

    Can I keep the ID without prefix if it works?

    Plugin Support Neo WhiteRabbit

    (@longnguyen89)

    Hi,

    Yes, if changing the post ID works on your site, you can keep the current ID without using the prefix. Not sure why this does not work on your end but you can read the difference between false and null here https://stackoverflow.com/questions/137487/null-vs-false-vs-0-in-php

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Advanced Image field does not save’ is closed to new replies.