Skip to content

Disabling Website URLs in WordPress Comments

These days a lot of spammers submit spam comments that are perfectly legitimate apart from the fact that they link somewhere. So I thought I would disable the website url field in the comments so that comments can focus on conversations rather than self promotion.

The code to do this was fairly straight forward. You just need to add the code below into your themes functions.php (or make a plugin that does it for you).

/**
 * Disable comment author links
 *
 * @param type $author_link
 * @return string
 */
function bm_disable_comment_author_links( $author_link ) {

    return strip_tags( $author_link );

}


/**
 * Remove URL field from comments
 *
 * @param array $fields
 * @return string
 */
function bm_comment_form_fields( $fields ) {

    $fields['url'] = '';

    return $fields;

}

add_filter( 'get_comment_author_link', 'bm_disable_comment_author_links' );
add_filter( 'comment_form_default_fields', 'bm_comment_form_fields' );

Ben View All

Ben is a lifelong Nintendo fan who also likes to build websites, and develop games. He also buys way too much Lego.

2 thoughts on “Disabling Website URLs in WordPress Comments Leave a comment

Leave a Reply

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