WordPress Profanity Filter

Filter comments in WordPress with a small plugin or functions.php hook using wp_remote_post.

Quick start in WordPress

add_filter('preprocess_comment', function ($comment) {
  $res = wp_remote_post('https://api.theprofanityapi.com/v1/check', [
    'headers' => [
      'Authorization' => 'Bearer ' . getenv('PROFANITY_API_KEY'),
      'Content-Type'  => 'application/json',
    ],
    'body' => wp_json_encode([
      'text' => $comment['comment_content'],
      'context' => 'comment', 'mode' => 'balanced',
    ]),
  ]);
  $data = json_decode(wp_remote_retrieve_body($res), true);
  if (!empty($data['flagged'])) {
    wp_die('Your comment was flagged. Please revise it.');
  }
  return $comment;
});

Why context-aware matters

A plain word list flags "this game is sick" or medical text full of anatomical terms. The Profanity API runs a five-layer pipeline that scores intent, so "die" in a gaming taunt and "die" in a real threat are handled differently. Pick a context and the engine adjusts strictness automatically.


Other integrations

Ready to ship moderation?

Get an API key and 300 free requests a month. No credit card required.

Get started free →