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.
Related Posts:
- What’s the most efficient database method to add and query usermeta?
- Extend the wp_users table
- update_user_meta() does not work
- Select Multiple meta_value from WP DB; Single Query
- Is it possible to store visitors IPs in wp_postmeta table?
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- A field with dashes in the slug [closed]
- In what part of the WordPress core does the users table and usermeta table get joined?
- Modify Database in Multi-Site wp_usermeta table
- Best way to tell if a user account is active, using the database only
- Using GROUP CONCAT in my-sql query with wp_usermeta table
- Is it safe to delete unnecessary user metadata?
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- WordPress Database Huge wp_usermeta Table
- How to Access wp_usermeta Data Immediately After a New User is Created
- What can I do when an outside party hacks into my weblog and changes my display name?
- Users table missing from Database [closed]
- Recovering the table wp_usermeta from users
- I cannot find the difference between these wp_capabilities values in wp_usermeta
- Buddypress avatar image in database [closed]
- Storing user submitted forms [closed]
- wp_insert_user not creating account correctly when ID is manually set
- Compare User meta_value with Product meta_value
- Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
- Join Query on WP_USERMETA Table
- how add more field to wp user and save it to database
- Move Non-WordPress users table to WordPress database
- generate PDF from member information
- How to get the id of recently registered user from database?
- update multiple user meta field based on another meta field
- get_user_meta and umeta_id
- Preventing concurrent update of data
- Calling update_user_meta inside of another function doesn’t work
- wp_usermeta key problem
- Query a meta key using an array of values where the database value is a string
- Checking if Database Table exists
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- Syncing local content with development / staging sites
- Export WP database for import using WP-CLI on Vagrant Box
- Improve or optimize a very slow query
- What is the advantage of separating wp_users and wp_usermeta table?
- “MySQL server has gone away” since update to 3.8
- WordPress page title repeated in SOME pages
- Why is $wpdb->get_results failing on certain tables but not others (which have data)?
- How to correctly add a table to the WordPress MySQL database
- MySQL Syntax Error upon restoring database from backup [closed]
- Help running a MySQL query to update all wp_#_options tables in a Multisite install
- Is it safe to convert tables from MyISAM to InnoDB?
- Use one WordPress database with multiple instances of one site
- Who is responsible for data sanitization in WordPress development?
- How do I properly update the WordPress database password?
- How to check if a core update, like 4.9.8 → 5.0, involves a database update (migration)?
- $wpdb->insert is not working
- WordPress Install and Database on separate hosting?
- Moving a site from a temporary domain to the live domain [duplicate]
- Moving minor updates between local and live sites – just database?
- what is the best way to store user created data?
- WP get stuck with a query on MySQL when the site is resumed
- How to move the WordPress site Layout from test site to Production site?
- Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Retrieve data from the database to table such as comments in the admin control panel
- Need to store custom user information (many-many relationsips), preferably not as user meta
- charset problem with new custom table
- WordPress and user security
- How to share plugin created database tables between two WordPress sites
- How to connect to a remote database in WordPress?
- Migrating from PDO using SQLite to clean new install using MySQL
- Change WordPress URL in sql file via Terminal
- $wpdb->insert Giving duplicates
- Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?
- Where is phpMyAdmin inside WordPress?
- How to delete database without using any plugin?
- Cannot restore wordpress database from sql dump [closed]
- WooCommerce: remove sample & dummy data
- Is database deleted on clicking “reinstall” button in WordPress updates?
- Is my way to change WordPress server is correct?
- WordPress database products structure
- Files on Localhost, Database on Server
- Is there any way to monitor a MySQL db and check what has changed?
- DB prefix not updating
- Any other way of storing plugin admin data setting
- Will memcached improve performance with WP Super Cache already running?
- Restore of database doesn’t show content
- Why theme settings lost when I installed https
- WordPress site migration – locked out of admin area
- WordPress users table missing indexes
- unable to use my wordpress site after moving
- How to add download link from database on custom page template?
- insert data from a form:: Warning Empty query mysqli::query()
- Get meta_query value by user meta array
- Db connection problem on Azure Since database moved on CLEARDB
- Mysql Queries per Visit – Crazy High
- Media Library doesn’t allow uploads? Upload Directory
- using same mysql user with many databases
- Manage 3 Layers Of Information (CTP – Posts – Then Maybe Metadata?)
- Get id from database
- $wpdb->insert not working for last select option
- How to create a table [closed]
- Upload wordpress from localhost to 000webhost
- How to properly configure SSL connection to remote azure database for running queries within a WordPress environment