I want to store some information with my new custom table in WordPress website, whenever admin create update or delete any post or page that time some information store my custom table.
Below my custom table operations
Operations:
id,User_id,operation_type,table_name,row_id,operation_at,created_at,updated_at.
user_id (post_author)
operation_type (add/update/delete etc),
table_name (which table add/update/delete),
row_id (post r page own id),
operation_at (that time when admin add/update/delete),
created_at (operations table current time),
updated_at (operations current time),
how can implement this code?
Thanks
2
Answers
You can use the following hooks:
I don’t know what do you want to do exactly, but you can insert data with https://developer.wordpress.org/reference/classes/wpdb/insert/
/* You can use these 3 action hooks to have a functionality after update, insert and delete a post respectively. */
/* This function is only for update a post. You have all the hooks for each action just call a function after any specific action */
I hope it will solve your problem.
If you have any problem regarding inserting into a table you might need to look into this. https://developer.wordpress.org/reference/classes/wpdb/insert/