简体   繁体   中英

Wordpress user_login field on new table field

I am using wordpress and I've created a new table in the wordpress database.

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?

Well, to make a one time copy of the user_login field into your new table, you would do this:

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. Also, make sure your user_login column has the same (or compatible) data type as user_login in the original users table

Now, if you want to replicate the user_login automatically whenever a new user is created, you should look into creating a trigger.

Read those on how to create a trigger:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM