Home Forums General Issues Interpreting user meta value


Interpreting user meta value

  • I’m looking at an old site where a custom design involved a custom field for adding a photographer. I can see in the database that this value was stored simply as the user id, making lookup easy.

    Now I’m building the replacement site and using ACF for this function. But when ACF saves the content of a user field type, the meta value looks like an array with a few items, one of which is the user id. (I don’t mean the array of user meta values that’s yielded by get_field.)

    Now that I want to import the old posts, what transformation should I apply to my old user id values to have them look like ACF ones?

    (Note: I’ve made sure all the actual user ids are the same; there’s no need to change them. I just need to change the surrounding text…)

  • Is this something like what you are seeing? a:1:{i:0;s:1:"1";}
    That is an array of user IDs in serialized format. In this case an array with one element. To get this you can convert using something like:
    <?php serialize(array($user_id)); ?>

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Interpreting user meta value’ is closed to new replies.