Search for answers or browse our knowledge base.
How to mirror the WordPress activity log to Slack
The WP Activity Log plugin can be configured to mirror your WordPress activity log to a Slack channel of your own choice. The WordPress activity log is mirrored to third party services in real time, so you can see what is happening on your site in real time directly from your third party service of choice.
This document explains how you can do this. In short the process consists of three easy steps:
- Create an App with an incoming Webhook in Slack
- Set up a Slack connection in the WP Activity Log plugin
- Configure the mirroring of the activity logs to Slack
1. Create an App with an incoming Webhook in Slack
For the plugin to send logs to a Slack channel, you need an incoming Webhook. The below explains how you can create one. Please note that this is a basic explanation of how you can configure Slack. For more detailed information please refer to the documentation on the Slack website.
- Navigate to https://api.slack.com/apps.
- Click Create an App and select From Scratch.
- Name the App and select a workspace in which the App will work from the drop-down menu.
- Once you are in the Basic Information page for the app, click on Incoming Webhooks.
- Set the Incoming Webhooks to On and click Add New Webhook to Workspace.
- When you are redirected to the App page, you will see the new Webhook URL at the bottom of the page. Click Copy to copy the URL. You will need this when setting up the Slack connection in WP Activity Log.
2. Create a Slack connection in the plugin
Once you create an App on Slack and have an incoming Webhook URL, follow the below procedure:
To setup a Slack connection in the activity log plugin:
- Click on the Integrations node in the plugin menu.
- Click the Create a Connection button to launch the connection setup wizard.
- Select Slack from the Type of Connection drop down menu in the first step of the wizard.
- When the plugin completes the requirements test, click Next.
- Paste the Webhook URL you’ve copied in the previous steps in the WebHook URL placeholder and click Next.
- When the plugin completes the test, specify a name for the connection. The connection name is the friendly name that is used in the plugin. They can be up to 25 characters long and can only consist of letters, numbers and underscores.
- Click Save Connection to close the wizard.
Testing the Slack Connection
Once the connection is setup it will be listed in the Connections tab. Click the Test button to send a test message to the configured Slack channel via the plugin and confirm the configuration.
3. Configuring the mirroring of the activity log to Slack
Once the Slack connection has been configured, configure the mirroring by following the below instructions:
- Click on the Integrations node in the plugin menu.
- Navigate to the Mirroring tab and click the Setup an Activity Log Mirror button.
- In the first step of the wizard specify the following:
- Friendly name for the mirror.
- Mirror identifier in logs (this will be added to each even, so you know the source of the activity log event).
- Select the Slack connection you’ve just setup from the Connection drop down menu.
- In the second step of the wizard specify if you want the mirroring to start right away.
- In the last step of the wizard you can configure activity log filtering rules for the mirroring connection. By default the connection is set to Send all events option, though if you’d like to setup any filtering rules refer to configuring filtering rules for activity log mirroring connections.
- Click Save mirror to save the new mirroring process.
WordPress activity log in your Slack channel
That is it. Now the plugin will send a copy of the activity log events to your Slack channel as they happen, in real time!
Restrict log writing to mirror only
Once the mirroring setup process is complete, and WP Activity Log has successfully started writing to Slack, you will have the option to stop writing activity logs to the database. While this will help you prevent redundant data, do keep in mind that the plugin will only write activity logs to the configured mirror(s).
To stop writing activity logs to the database, switch off the Write activity log to database option as available in the Mirroring tab.
More information & other integrations
Refer to getting started with mirroring the WordPress activity log for more information on the format of the logs, the third party services the plugin can mirror activity logs to and other technical details.