If I update WordPress my custom data will be deleted from the wp_users table? I add new custom field and store data to users at this field if I update WordPress and WordPress needs to update this table my custom field will be deleted?
It is possible, especially if the update includes changes to the user table. The only way to be sure is to test it, but for future reference:
Never modify the scheme of WordPress Tables
If you need to add additional information about something, WordPress provides meta, user meta, site meta, post meta, comment meta. You may know these as custom fields.
$value = get_user_meta( $user_id, 'example', true ); update_user_meta( $user_id, 'example', 'newvalue' ); $all_meta = get_user_meta( $user_id );
Adding columns manually to tables also bypasses the caching layer slowing things down, encourages writing manual SQL statements ( you could have used the
WP_User_Query class! ), and stops the information being imported/exported ( custom post types get put in content exports, custom tables don't )
I recommend writing a small WP CLI command to fetch each user and store these columns as user meta instead
No, your Custom User Data (i.e. User Meta) will remain safe in database even after you update your WordPress. I've not seen so far the WordPress Updater touching/altering the data in any of the tables.
(Just to keep posted, it's the
[prefix]_usermeta table that holds the user related data; not the