0

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?

2
  • Do you mean user meta, or did you modify the table itself to add new columns?
    – Tom J Nowell
    Commented Jun 22, 2017 at 13:21
  • @TomJNowell The table itself (wp_users)
    – Yogu
    Commented Jun 22, 2017 at 13:51

2 Answers 2

1

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.

For example:

$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

0

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 [prefix]_users table.

1
  • I totally understand you but in my case, i don't add this data as user meta I add this data directly info wp_users I add new field after display_name field and store the data into it, So my question are you sure that if I update WordPress this custom field not be deleted? Thank you for your time.
    – Yogu
    Commented Jun 22, 2017 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.