Simple History 5.8.0 released

🔍 This release adds support for custom log entries and also adds logging when a user gets an access denied message when trying to view an admin page that they do not have access to.

New: Support for custom log entries

With this release it is now possible to add custom events to the log manually, using the REST API or using the WP-CLI. Premium users can even add events using a simple GUI!

Manual entries can be useful for a large variation of things:

  • Add a message from Github, Gitlab, or similar, to the log everytime a new website deployment is done.
  • An admin can add a message to the log to notify users about important changes to the website.

Entries can be added by administrators using the REST API. Those requests must be authenticated using for example application passwords.

Entries can also be added directly on a server using WP-CLI. When using WP-CLI all users with access to WP-CLI can add manual entries.

Custom entries can be seen by all users who have access to the log.

WP REST API examples

Here are some examples on how to add custom entries using the WP REST API:

# Example 1: Basic usage - add a simple event
curl -X POST http://wordpress-stable-docker-mariadb.test:8282/wp-json/simple-history/v1/events \
--user "<username>:<application-password>" \
-H "Content-Type: application/json" \
-d '{"message":"Hello from REST API"}'

# Response:
# {"message":"Event logged successfully","data":{"status":201}}

# Example 2: Advanced usage - add event with additional details
curl -X POST http://wordpress-stable-docker-mariadb.test:8282/wp-json/simple-history/v1/events \
--user "<username>:<application-password>" \
-H "Content-Type: application/json" \
-d '{"message":"Deploy successful","level":"notice","note":"Deploy id: OKL-473-IYE. Source: GitHub actions."}'

# Response:
# {"message":"Event logged successfully","data":{"status":201}}

# Example 3: Authentication required error
curl -X POST http://wordpress-stable-docker-mariadb.test:8282/wp-json/simple-history/v1/events \
-H "Content-Type: application/json" \
-d '{"message":"Hello from REST API"}'

# Response:
# {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":401}}

WP-CLI examples

Here are some examples on how to add messages using WP-CLI:

# Example 1: Minimal example - add basic message with default settings
wp simple-history event add "This is a message added via WP-CLI"

# Example 2: Basic usage - add a simple notice
wp simple-history event add "The website will be updated to a new theme next monday. /The web dev team" --level=notice

# Example 3: Add a warning with additional note details
wp simple-history event add "Watch out for email phishing attempts" --level=warning --note='At the moment there are many of our users who receive emails that says they come from our IT-department. Do not click on any links in email that you get!'

Added entries will look similar to this:

Add custom event entries using a GUI

If you want to add your own messages to the log but don’t want or know how to use the WP REST API or WP-CLI there is an option in the premium add-on to add log messages using a GUI.

Adding event manually will look something like this in the log:

Also new: log denied access to admin pages

If a user attempts to access an admin page they don’t have permission for, this is now logged in the User Logger. This can help admins to catch faulty plugins or help users that tries to visit pages from bookmarks or similar, that have changed locations.

So whenever a user faces a page like this in the admin:

Those visits are now logged:

Full changelog

Added

  • Add logging of admin page access denied events. When a user attempts to access an admin page they don’t have permission for, this is now logged in the User Logger.
  • Add new Custom_Entry_Logger logger that adds support for custom entries to be added via WP-CLI and REST API.
    • Only administrators (users with manage_options capability) can add custom log entries using the REST API.
    • Users with access to WP-CLI can add custom log entries.
    • See the release post for examples and screenshots of how to use custom entries.
    • (There is also an option in the Premium add-on to add custom entries via the UI.).

Fixed

  • Fix rare options key missing error when retrieving logger search options.