How to delete events with a specific event ID from the activity log

You are here:
Back to KB search

Two features that really set WP Security Audit Log apart from all the other activity log plugins are the level of detail of the logs and the coverage the plugin has.

WP Security Audit Log does not just keep a log that a post was updated. It keeps a log of what was updated in the post. Example: the plugin reports the the changed value, the custom field’s name, the post’s name and more when a custom field in a post is updated.

However, if something goes wrong, this level of detail can also pollute the activity log. This happens when for example plugins automatically update data in WordPress. Such as, a plugin that automatically updates a custom field value every time someone visits a post.

When this happens you can exclude the custom field from the activity log, or disable that specific event ID, so no more events are reported. Though what about the events that were generated before you took the necessary action? You can always delete them, as this post explains.

Deleting events with specific ID from the WordPress audit log

The activity log is saved in the WordPress database. So all you need is to run a SQL statement that deletes all the events with a specific event ID. Here is the SQL statement:

DELETE occ, meta FROM wp_wsal_occurrences as occ INNER JOIN wp_wsal_metadata AS meta on occ.id = meta.occurrence_id WHERE occ.alert_id='9999';

Before you run the above SQL statement:

  • wp_wsal_occurrences and wp_wsal_metadata are the table names. If you use a different table name prefix change it in the query,
  • 9999 is an example event ID. Replace this number with the ID of the events you want to delete. Refer to the complete list of activity log event IDs to find to which action or change every ID is associated with.