In my site i need to store 200 extra data for each user. Now i know about the user meta option. But is it a good way to save 200extra field for each user?
Or should i create an extra table in the database to do the work.
In my site i need to store 200 extra data for each user. Now i know about the user meta option. But is it a good way to save 200extra field for each user?
Or should i create an extra table in the database to do the work.
You can store multiple pieces of data within a single field by passing an array rather than a string:
$user_data = array(
'favorite_color' => 'blue',
'favorite_animal' => 'cat',
'favorite_city' => 'paris'
);
update_user_meta( $user_id, 'user_data', $user_data );
WordPress will serialize this data for you on save, and unserialize back into an array when it is retrieved:
$user_data = get_user_meta( $user_id, 'user_data', true );
echo $user_data['favorite_color'];
The caveat is that it will actually result in a slightly larger amount of data, but it will decrease the number of rows consumed by the data.