Make WordPress Core

Opened 7 months ago

Closed 7 months ago

#64129 closed feature request (wontfix)

For Preventing Spams

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

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
7 months ago

  • Focuses ui sustainability removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Severity changed from major to normal
  • Status changed from new to closed
  • Version 6.8.3 deleted

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.