WP Slack Plugin Sends Notifications to Slack Based on Events Triggered in WordPress

In a matter of months, Slack has managed to become the favorite communication tool for thousands of businesses, boasting more than 250,000 daily active users, with roughly 30% of them paying for the service. The company recently acquired $120 million to fund further growth and is now valued at $1.1 billion dollars.

While Slack helps teams get things done together, much of the actual work happens outside of the app. That’s why the Slack API offers the ability to add new Incoming WebHooks to integrate outside services. With WordPress powering 23%+ of the world’s websites, it’s important to have an easy way to bring in notices from those sites.

Self-hosted WordPress installations have the option of using the Slack plugin, created by Akeda Bagus, a developer with X-team. Last week we featured the bbPress Slack Integration plugin, which allows you to send notifications of new bbPress topics and replies to your Slack channel of choice. WP Slack performs a similar function for general WordPress events.

The plugin is capable of notifying Slack, based on a few basic events:

When a post needs review (status transitioned to ‘pending’)

When a post is published

When there’s a new comment

Additionally, it includes a slack_get_events filter for adding more events. The documentation provides an example of creating a new event that will notify Slack when a user is logged in:

[php light=”true”]add_filter( ‘slack_get_events’, function( $events ) {
$events[‘user_login’] = array(
‘action’ => ‘wp_login’,
‘description’ => __( ‘When user logged in’, ‘slack’ ),
‘message’ => function( $user_login ) {
return sprintf( ‘%s is logged in’, $user_login );
}
);

return $events;
} );[/php]

Configuration inside the WordPress admin is simple. Once you’ve set up the webhook with Slack, you simply paste it into the Service URL field when setting up an integration:

WP Slack allows you to set up multiple integrations so you can send notices to different channels. Notices can also be temporarily deactivated and turned back on a later time. When you finish setting up an integration, the plugin allows you to fire off a test notification to ensure that it’s working correctly.

Bagus has also developed a suite of free extensions that notify Slack based on events triggered by other plugins:

Slack EDD

Slack WooCommerce
Slack Contact Form 7

Slack Gravity Forms

These plugins make it possible to keep your team notified of new orders on a WooCommerce or EDD-powered store, or even website inquiries from your site’s contact form. Each extension requires the Slack plugin to be installed first.

While the plugin author hasn’t announced plans to add this feature, it might be useful to have support for Outgoing Webhooks as well. That would make it possible for WordPress to get information back from Slack based on public triggers used in the channel. The possibilities for this could be interesting. For example, you could set up a trigger that automatically creates a new draft or perhaps publishes a one-sentence summary of a quick meeting.

The Slack plugin for WordPress is available in the official Plugin Directory. You can also find the project on GitHub where pull requests are welcome.