Storing PHP Arrays in Wordpress User Meta Database Storing PHP Arrays in Wordpress User Meta Database wordpress wordpress

Storing PHP Arrays in Wordpress User Meta Database


You need to set the last parameter from false to true:

$wp_user_film_prefs_arr = get_user_meta( $wp_user_id, $wp_user_film_prefs_key_label, true );

That third parameter is $single:

(boolean) (optional) If true return value of meta data field, if false return an array.

Default: false

That might sound contra-productive in your eyes, but the meta data field can contain multiple values. In your case you don't need that, but the single value. The single value is your array.

See as well: get user metaCodex


Have you consider serialize() it as a str and store this str into your db, and unserialize() the str into array after getting from db?