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' );
Was it good/ useful/ a load of old rubbish? Let me know on Mastodon, or BlueSky (or Twitter X if you must).
Link to this page
Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.