[wp-trac] [WordPress Trac] #62703: Do not allow to leave a comment that contains prohibited keywords

WordPress Trac noreply at wordpress.org
Wed Dec 18 05:26:59 UTC 2024


#62703: Do not allow to leave a comment that contains prohibited keywords
-----------------------------+------------------------------
 Reporter:  tunyk            |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Administration   |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:  administration
-----------------------------+------------------------------
Changes (by abcd95):

 * component:  Security => Administration


Comment:

 Thanks, @tunyk, for the suggestion! I think it's a great idea to prevent
 spam and hacky comments from entering the system rather than accepting and
 then trashing them.


 I believe the change would involve extending
 `wp_check_comment_disallowed_list()` to either continue with the current
 trash behavior or return an error for blocking the disallowed message,
 whichever action is preferred by the admin.

 We can add a condition [https://core.trac.wordpress.org/browser/trunk/src
 /wp-includes/comment.php#L1389 here] to block the posting of disallowed
 comments

 {{{#!php
 if ( $blocking_disallowed_comment ) {
         return new WP_Error(
             'comment_disallowed',
             __( 'Sorry, this comment cannot be submitted as it contains
 prohibited content.' ),
             403
         );
 }
 }}}

 I do invite discussions if there are better ways to handle this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62703#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list