• Resolved WWDP

    (@wwdp)


    Hi,

    I use the option to save meta-boxes as unserialized fields by adding the ‘wck_cfc_unserialize_fields_’-filter in my functions.php.

    All works fine if i add or update meta-fields in the adminpanel and hit ‘Save changes’. But when i use ‘update_post_meta’ in my code to add or update metafields the unserialized-function isn’t triggered.

    Is it possible to trigger this functionality manually from within my code? I need it to add/update metafields after submitting a form.

    https://www.ads-software.com/plugins/wck-custom-fields-and-custom-post-types-creator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Cristian Antohe

    (@sareiodata)

    It can be done but I don’t know how to do it out of the top of my head.

    Basically you’ll want to add and action here: https://core.trac.www.ads-software.com/browser/tags/3.9.1/src/wp-includes/meta.php#L248
    updated_{$meta_type}_meta

    Then check to see if the meta_key is the WCK meta_key.

    If it is, read the meta value or the meta key, and do something like this for a single metabox:

    $meta_suffix = 1;
    if( !empty( $single_values ) ){
        foreach( $single_values as $name => $value ){
            update_post_meta( $post_ID, $meta_name.'_'.$name.'_'.$meta_suffix, $value );
        }
    }

    If it’s a repeater, then you’ll need to make changes to the above to take into account the multiple array.

    Please note I haven’t tested any of this. But logically speaking it should work.

    Thread Starter WWDP

    (@wwdp)

    Hi,

    Sorry for my late response. A little busy these days…..

    Thanks for your solution. After some tweaking it works great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trigger 'save unserialized fields' when using 'update_post_meta'’ is closed to new replies.