get_user_meta($user_id); returns serialized values in second level array
-
I’m using get_user_meta(); And it returns something in the style of
[user_meta] [metakey] [0] => "Serialized value here"
Now from my feeble understanding this seems to be intended behavior since in get_metadata
there is these lines:if ( !$meta_key ) return $meta_cache;
that are right before the maybe_unserialize:
if ( isset($meta_cache[$meta_key]) ) { if ( $single ) return maybe_unserialize( $meta_cache[$meta_key][0] ); else return array_map('maybe_unserialize', $meta_cache[$meta_key]); }
So depending on if a key is specified, get_metadata will return (possibly)serialized or unserialized values.
Is there a reason for this that I’m not catching?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘get_user_meta($user_id); returns serialized values in second level array’ is closed to new replies.