add_post_meta without serializing the array? (2 posts)

  1. Felix
    Posted 3 years ago #

    I'm trying to use add_post_meta to submit a multidimensional array.

    array( array (
    "key1" => "value1", "key2" => "value2", "key3" => "value3"
    ) )

    However, this serializes the array into a string, which I don't want because I'm using this data with a plugin.

    When I use update_post_meta with the same array, it works perfectly, however I'll only be able to submit one set of values this way.

    Is there any possible way to use add_post_meta without serializing the array?

  2. bcworkz
    Posted 3 years ago #

    I'm not sure what's going on here, all array and object data is serialized by both functions, whether you like it or not. But when you get_post_meta(), the data is unserialized back into an array or object, so it shouldn't make any difference to your plugin how it is actually stored, you should get back what you put into it.

    I can only imagine data somehow is being serialized twice, but only unserialized once.

Topic Closed

This topic has been closed to new replies.

About this Topic