How to remove commenters ability to add hyperlinks to comments?

WP runs so many prettifying filters on this stuff that it’s easy to get lost.

Here is what I ended up with:

remove_filter('comment_text', 'make_clickable', 9);
add_filter('pre_comment_content', 'strip_comment_links');

function strip_comment_links($content) {

    global $allowedtags;

    $tags = $allowedtags;
    unset($tags['a']);
    $content = addslashes(wp_kses(stripslashes($content), $tags));

    return $content;
}

This scrubs out clearly defined links and removes filter that turns plain text links into properly tagged ones.

Leave a Comment