最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Adding column to wpex_users

programmeradmin1浏览0评论

So I am trying to add a column to wpex_users. For some reason I cannot. This is my query:

ALTER TABLE wpex_users ADD nametest VARCHAR(200);

It gives me the error that my standard value is wrong. It is on NULL. I do not know what to do. I really need this new column.

Do you know the query I need to add a new column? I write the query in PHPMyAdmin.

So I am trying to add a column to wpex_users. For some reason I cannot. This is my query:

ALTER TABLE wpex_users ADD nametest VARCHAR(200);

It gives me the error that my standard value is wrong. It is on NULL. I do not know what to do. I really need this new column.

Do you know the query I need to add a new column? I write the query in PHPMyAdmin.

Share Improve this question asked Mar 19, 2020 at 12:22 Parsa_237Parsa_237 1117 bronze badges 1
  • You should not add columns to WordPress tables, when you update WP will remove the column and all that data will be erased, it is extremely bad practice, and dangerous – Tom J Nowell Commented Mar 19, 2020 at 13:47
Add a comment  | 

1 Answer 1

Reset to default 0

You should never modify the WP core tables, all your changes will be undone and the data lost the next time WP updates its table schema.

Instead, if you want to store more data on a user, do what other people do and use user meta:

  • update_user_meta
  • get_user_meta
  • add_user_meta
  • delete_user_meta

You can even query for it with WP_User_Query.

Otherwise, by adding custom columns, you'll have to write a tonne of SQL code from scratch, and risk major data loss.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论