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).