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

wp-slack

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:

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;
} );

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:

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

channel-notification

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

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.

Would you like to write for WP Tavern? We are always accepting guest posts from the community and are looking for new contributors. Get in touch with us and let's discuss your ideas.

6 Comments


  1. Awesome plugin which we’ve been using for a while now. Ryan Heller helped us for our website iCulture.nl to add (missing) custom post types support to WP Slack.
    Ryan kindly made this available via a pull request on Github, but the developer hasn’t made this publicly available via the plugin on the WordPres.org repository yet. But for whomever needs it, please find the pull request here: https://github.com/gedex/wp-slack/pull/24

    Report


    1. Hi Jean-Paul Horn,

      Thanks for the PR, I’ll take a look this week. Sorry for the delay.

      Report


  2. Did something similiar adding a notification whenever a new tag was added so our team knows about taxonomy changes. Slack has a great notifications API.

    Report


    1. What are you referring to? If it’s the Slack plugin, it looks like it’s still on the directory.

      Report


    2. Otto delisted the plugin temporarily because I forgot to ignore unnecessary files (bin directory that contains development-related files, mostly shell scripts). This might be web-accessible and potentially dangerous. I’ve removed that in 0.5.1 and the plugin is whitelisted now.

      Report

Comments are closed.