Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugins/Disemvoweler

The following is the plugin's raw PHP code. Simply copy the plugin code, paste it into a plain text document via a plain text editor, and save the file as disemvoweler.php.

Disemvoweler

This plugin removes vowels from comments posted from an IP in the disemvoweler blacklist. The idea is to remove trolls through humiliation, and has worked quite well in some forums.

<?php
/*
Plugin Name: Disemvoweler
Plugin URI: http://wordpress.org/#
Description: Removes vowels from comments posted from an IP in the disemvoweler blacklist.
Version: 1.0
Author: Ryan Boren
Author URI: http://boren.nu/
*/

//
// Add the IPS to disemvowel to this array.
//
$disemvowelIPs = array(
                       "0.0.0.0"
                       );

function disemvowel($content) {
    global $comment, $disemvowelIPs;

    if (in_array($comment->comment_author_IP, $disemvowelIPs)) {
        $content = preg_replace("/[aeiou]/i", '', $content);
    }

    return $content;
}

add_filter('comment_text', 'disemvowel');

?>

The following modification to the disemvowel function will replace the author's name with "troll" (just in case your trolls enter obscene names) and will remove his/her URL, if one was submitted. It also allows you to disemvowel a single comment (if disemvoweling all posts by an IP address is inappropriate) by editing the comment to include the string [troll] as the first part of the comment.

/* Modified disemvowel function from Ryan Boren's disemvoweler plugin.
 *
 * Replaces authors name with "troll" and removes the URL
 * Also allows a single comment to be disemvoweled by inserting the
 * string [troll] as the first line of the comment.
 *
 * Modified by Mark McIntyre
 */
function disemvowel($content) {
    global $comment, $disemvowelIPs;

        $troll = ereg("^\[troll\]", $content);
    if (in_array($comment->comment_author_IP, $disemvowelIPs) || $troll) {
          if($troll)
             $content = substr($content, 7);
        $content = preg_replace("/[aeiou]/i", '', $content);
        $comment->comment_author = "troll";
        $comment->comment_author_url = "";
    }

    return $content;
}