Make WordPress Core

#64129 closed feature request (wontfix)

For Preventing Spams

Reported by: yogi5 Owned by:
Priority: normal Milestone:
Component: Comments Version:
Severity: normal Keywords:
Cc: Focuses:

Description

Hello there,

this is to prevent spams :

in the comment box you can set an action where we can remove the website fields from the comment box because due to providing website box to visitors we invite more spams rather than comments.

So, kindly act on this that website owners remove website fields from comment box.

thank you
Yogesh Vyas

Change History (1)

#1 @peterwilsoncc
13 months ago

  • Focuses ui sustainability removed
  • Milestone Awaiting Review
  • Resolution → wontfix
  • Severity major → normal
  • Status new → closed
  • Version 6.8.3

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

Note: See TracTickets for help on using tickets.