Title: logging options table activity
Last modified: March 24, 2025

---

# logging options table activity

 *  Resolved [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/)
 * Hi,
 * Does Simple History (or Simple History Premium) log calls to update_options()
   or delete_options()? If not, would it be possible to add that functionality?
 * Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18382965)
 * Hi! Not at the moment – but this is something I can easily add. If you like you
   can send me an email at the adress found at [https://simple-history.com/contact/](https://simple-history.com/contact/)
   and later this week I should have a working version that I can send for you to
   test. If you have any specifics about how you would like the output of the options-
   logging to be just let me know!
 *  Thread Starter [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18383704)
 * Good to hear. We have a case of the license key of a particular paid plugin “
   disappearing” every few months. I believe I’ve found some code which explains
   it, but I’d love to “catch it in the act” so to speak by seeing a log where I
   found out what was deleting the option. I don’t know what you can trap, but I
   guess what I’m hoping to see is which option was deleted/updated, date and time,
   and hopefully which file executed the call to update_options/delete_options.
 * Might that be too many operations? I just don’t know, so maybe some way to filter
   that in the search (or even in the logging). Those are my preliminary ideas.
 * Thanks!
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18402724)
 * I think that would work fine. It will store a lot of data, but you only need 
   to have the “options logger” enabled during the “debug period”. The logger can
   show a short debug backtrace to hopefully determine what caused the options to
   be removed/updated. Drop me an email if you would like a beta version with this
   functionality.
 *  Thread Starter [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18403463)
 * Would there be a way to filter only logging certain options or excluding options,
   etc. ?
 * Thanks.
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18404765)
 * The code is pretty much this:
 * [https://gist.github.com/bonny/bbef255345b03df48c7a4828b7eba758](https://gist.github.com/bonny/bbef255345b03df48c7a4828b7eba758)
 * Add this code to a new file and include that and modify the array in `get_options_to_log()`
   to include the name(s) of the options you would like to track and then modifications,
   adds, and deletions of that option should be logged.
 *  Thread Starter [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18407113)
 * So, once implemented, I would modify get_options_to_log() in **[simple-history-log-options-update.php](https://gist.github.com/bonny/bbef255345b03df48c7a4828b7eba758)**
   to only log what I want – correct?
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18407120)
 * Yes, exactly. It still needs to be an array however, even if you only add one
   value there.
 *  Thread Starter [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18407133)
 * Logical.
 * And **[simple-history-log-options-update.php](https://gist.github.com/bonny/bbef255345b03df48c7a4828b7eba758)**
   is part of the core of the plugin so I imagine that across plugin updates, I’ll
   need to maintain any changes there that I make?
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18411106)
 * It depends on how you add this file. I would not add it to any existing plugin(
   not even Simple History) but rather a new plugin or directly in your theme if
   you have a custom theme. Let me know if you need it as a separate plugin, I can
   quickly fix that 🙂
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18411134)
 * Ok I did create a plugin of it now instead.
 * Below is the update code. Just create a folder in your plugins folder, i.e. `
   simple-history-options-logger` and then place the file below in this folder (
   so you have `simple-history-options-logger/simple-history-options-logger`). Then
   go to wp admin » plugins and activate the plugin. Then it’s not modified by other
   theme or plugin updates. Good luck!
 * [https://gist.github.com/bonny/29e0818051525b1a4f52c75a58244a3c](https://gist.github.com/bonny/29e0818051525b1a4f52c75a58244a3c)
 *  Thread Starter [dleigh](https://wordpress.org/support/users/dleigh/)
 * (@dleigh)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18411338)
 * Wow – so generous of you!
 * So for this particular plugin, I’ve chosen 10 options to “monitor”. One of them
   is obviously being referenced by a cron job as it is showing up with a log entry
   every couple of minutes.
 * Unfortunately this is the message returned:
 * **Option “wawp_disabled” updated from “” to “”**
 * I looked at the code but it’s not obvious to me where it’s doing its comparison
   from the old to the new value and how it might interpret this as a “difference”
   between the old and new value.
 * Any ideas?
 * Thanks!
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18442222)
 * [@dleigh](https://wordpress.org/support/users/dleigh/) Sorry for the late reply.
   When looking at the code again I think the reason you see “” instead of a value
   is most likely because the old and new values are objects or arrays. I didn’t
   think of that when I wrote the code. If you click the data/time of the event 
   a modal is shown where you can see a more “raw” version of the data. See if old_value
   or new_value have values that are not “” there.
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18442262)
 * After some more testing I think you should change the code below comment “// 
   Log the update” to this to prevent further problems with arrays or objects:
 *     ```wp-block-code
           // Log the update.    \SimpleLogger()->info(        sprintf( 'Option "%s" updated', $option ),        [            'context'   => 'options',            'option'    => $option,            'old_value' => $old_value,            'new_value' => $value,            'backtrace' => $backtrace_info['trace'],            'backtrace_summary' => $backtrace_info['summary'],        ]    );
       ```
   

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘logging options table activity’ is closed to new replies.

 * ![](https://ps.w.org/simple-history/assets/icon.svg?rev=3225008)
 * [Simple History – Track, Log, and Audit WordPress Changes](https://wordpress.org/plugins/simple-history/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-history/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-history/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-history/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-history/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-history/reviews/)

 * 13 replies
 * 2 participants
 * Last reply from: [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/logging-options-table-activity/#post-18442262)
 * Status: resolved