$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>revisions - Is there a way to determine which user changed a custom field (and when)?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

revisions - Is there a way to determine which user changed a custom field (and when)?

matteradmin10PV0评论

A custom field on posts in my Wordpress installation stores an image URL. I need to know when this custom field was updated, and by which user, for a particular post.

I know this data is not stored in the built-in Revisions feature, but is there some way to tell from the database?

A custom field on posts in my Wordpress installation stores an image URL. I need to know when this custom field was updated, and by which user, for a particular post.

I know this data is not stored in the built-in Revisions feature, but is there some way to tell from the database?

Share Improve this question asked Jan 31, 2019 at 13:51 Edmund HeaphyEdmund Heaphy 1531 gold badge2 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

By default, no. When WP Core saves postmeta (i.e. custom fields) in the database, it associates it to the parent post - not the current revision, and the database does not store a timestamp for when postmeta was stored.

If you want to keep track of future postmeta changes, you can add code to version it. This will associate the postmeta to the corresponding revision ID, instead of the parent post ID. Then, if you come across a page with postmeta you want to track down, you can check in the database, revision by revision: search for the postmeta where the meta_key corresponds to that piece of data (this will be the name of your custom field) and where the post_id equals the ID of the revision you're checking. Once you find the oldest revision ID where that postmeta was set, you can then check in the revision history to see who the author was of that revision, which is the person who changed the postmeta to that value.

Post a comment

comment list (0)

  1. No comments so far