Support General rwmb_after_save_post Reply To: rwmb_after_save_post

#13100
Anh TranAnh Tran
Keymaster

Hmm, couldn't find anywhere the JSON value is stored.

However, I found something confusing in your code:

This part:

if( is_string($field['value']) && is_array(json_decode($field['value'], true)) ) {
        $array = json_decode( $field['value'] );
        $i = 0;
        foreach( $array as $value) {
          update_post_meta($post_id, '_property_' . $new_level . '_' . $field['key'], $value[$i]);
          $i++;
        }
      } else {...}

Here you check if $field['value'] is a json-string. But when you decode it with $array = json_decode( $field['value'] );, then $array will be an object! Not sure why the next foreach loop work.