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' );

Let me know what you think on Mastodon, or BlueSky (or Twitter X if you must).

WordPress News

The latest WordPress updates from the WPBriefs Podcast.

Related Posts

20 Jul 2016

Empathy in Web Design

I wasn’t able to make WordCamp Europe this year, but they’ve been really quick at getting all of the talks online, and so I have been watching some of them – and this one stood out.Morten Rand-Hendriksen is an experienced...
25 Nov 2010

WordPress Advent – Seasonal WordPress Savings

In January or February this year I had the idea of making some sort of advent calendar website for christmas. I wanted to share something with the online community – I just wasn’t sure what.In mid October I started thinking...