[wp-trac] [WordPress Trac] #64129: For Preventing Spams
WordPress Trac
noreply at wordpress.org
Tue Oct 21 22:42:11 UTC 2025
#64129: For Preventing Spams
-----------------------------+----------------------
Reporter: yogi5 | Owner: (none)
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Comments | Version:
Severity: normal | Resolution: wontfix
Keywords: | Focuses:
-----------------------------+----------------------
Changes (by peterwilsoncc):
* status: new => closed
* focuses: ui, sustainability =>
* severity: major => normal
* version: 6.8.3 =>
* milestone: Awaiting Review =>
* resolution: => wontfix
Comment:
Hi @yogi5 and welcome to trac!
This is already possible via filters available in WordPress. As most spam
bots don't use the comment form, you would need to include code to prevent
the comment from being submitted.
As a very basic approach you could do something like this:
{{{#!php
<?php
add_filter( 'comment_form_field_url', '__return_empty_string');
add_filter( 'comment_form_field_cookies', function ( $value ) {
if ( ! empty( $value ) ) {
$value = '<p class="comment-form-cookies-consent">
<input id="wp-comment-cookies-consent" name="wp-comment-
cookies-consent" type="checkbox" value="yes" checked />
<label for="wp-comment-cookies-consent">' . __( 'Save my
name and email in this browser for the next time I comment.', 'plugin-
text-domain' ) . '</label></p>';
}
return $value;
} );
add_filter( 'preprocess_comment', function( $comment_data ) {
if ( ! is_user_logged_in() && ! empty(
$comment_data['comment_author_url'] ) ) {
wp_die( 'Error: Website URL field is not allowed.' );
}
return $comment_data;
} );
}}}
As the feature is already possible via a plugin, I'm going to close this
as unplanned.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64129#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list