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

Search Knowledge Base by Keyword

You are here:

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

WP Activity 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 activity 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';

Deleting events prior to a specific time from the WordPress activity log

If your are looking to remove events prior to a certain date, you may do so using the simple SQL query below. The UNIX time stamp at the end will be the date up to which you would like to delete so be sure to change this to the date of your choosing. To quickly determine the UNIX time for a specific date, a service such as this one can help.. 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.created_on < 1594937957;

Before you run the any of the above SQL statements:

  • 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.