[英]Wordpress user_login field on new table field
I am using wordpress and I've created a new table in the wordpress database. 我正在使用wordpress,并且已经在wordpress数据库中创建了一个新表。
I have created a new table which contains a userid field 我创建了一个包含用户标识字段的新表
My question is, is there anyway to make a copy save/sync wordpress's user table user_login field into my new table so that every time there's a new user my table is also populated with the user_login field? 我的问题是,是否有将wordpress的用户表user_login字段保存/同步到我的新表中的副本,以便每次有新用户时,我的表也都填充有user_login字段?
Well, to make a one time copy of the user_login
field into your new table, you would do this: 好吧,要将
user_login
字段一次性复制到新表中,您可以这样做:
insert into new_table (user_login)
select user_login from UsersTableNameHere
Warning: adjust script accordingly with table and column names, since and do not know WordPress DB structure, neither your new table's structure.
警告:请使用表和列名相应地调整脚本,因为并且不知道WordPress DB结构,也不知道新表的结构。 Also, make sure your
user_login
column has the same (or compatible) data type asuser_login
in the original users table另外,请确保您的
user_login
列具有与原始users表中的user_login
相同(或兼容)的数据类型
Now, if you want to replicate the user_login
automatically whenever a new user is created, you should look into creating a trigger. 现在,如果要在创建新用户时自动复制
user_login
,则应考虑创建触发器。
Read those on how to create a trigger: 阅读有关如何创建触发器的内容:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.