Using Akismet on WordPress Multisite

Akismet is a WordPress plugin for dealing with comment spam. It’s pretty good and simple to set up:

  1. Sign up for an Akismet plan (from free for a personal site, to $50 per month for enterprise).
  2. Use the API key generated to activate your plugin.

The API key (like a license key) is in the format abcde1f23456.

And that’s fine if you have only one site, but if you’re running WordPress multisite then you don’t want to have to activate Akismet individually for each sub-site. That’s just tedious.

Wouldn’t it be much better if you could just add the API key once?

Akismet doesn’t offer that option within the user interface on Multisite. Undeterred, I went in search of a way to do it.

How to do it

The wonderful folks over at WPMU DEV have a really useful blog post from July 2013 about how to do this: How to use Akismet on WordPress Multisite with 1 license key.

The good news it’s really simple:

  1. Open wp-config.php in your favourite text editor.
  2. The WPMU DEV article recommends that you add the API code  below the comment /* That's all, stop editing! Happy blogging. */ but I prefer to add it below the define() block for Multisite. But you can add it where you like, really.
  3. Add the following code define('WPCOM_API_KEY','abcde1f23456');
  4. Save wp-config.php and upload it to your site.

Your wp-config.php file will then look something like this:

[php]
/** Multisite */
define(‘WP_ALLOW_MULTISITE’, true );
define(‘MULTISITE’, true);
define(‘SUBDOMAIN_INSTALL’, false);
define(‘DOMAIN_CURRENT_SITE’, ‘www.example.com’);
define(‘PATH_CURRENT_SITE’, ‘/’);
define(‘SITE_ID_CURRENT_SITE’, 1);
define(‘BLOG_ID_CURRENT_SITE’, 1);

/** Define WordPress.com API key for Akismet in WordPress Multisite */
define(‘WPCOM_API_KEY’,’abcde1f23456′);
[/php]

Like many things on this blog I’ve added this here primarily for my own reference, but I hope it helps you too.

The real credit on how to do this, of course, goes to Sarah Gooding from WPMU DEV: thank you.

Happy spam-free blogging!

Published by

Gareth Saunders

I’m Gareth J M Saunders, 46 years old, 6′ 4″, father of 3 boys (including twins). Latterly, web architect and agile project manager at the University of St Andrews and warden at Agnes Blackadder Hall. Currently on sabbatical. I am a priest in the Scottish Episcopal Church, and I sing with the NYCGB alumni choir.

3 thoughts on “Using Akismet on WordPress Multisite”

  1. Below /* That’s all, stop editing! Happy blogging. */, I entered:
    {code type=php}
    /** Define WordPress.com API Key */
    define(‘WPCOM_API_KEY’,’xxxxxxxxx’);
    {/code}

    but I get a 500 error when I try to log in to the main site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.