[wp-trac] [WordPress Trac] #27140: possible bug in pre_comment_approved filter

WordPress Trac noreply at wordpress.org
Mon Feb 17 01:48:53 UTC 2014


#27140: possible bug in pre_comment_approved filter
----------------------------+-----------------------------
 Reporter:  realblueorange  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Comments        |    Version:  3.8.1
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 When using the pre_comment_approved filter, it seems the return value of 0
 does not function. A return value of 'spam' does what can be expected.

 This is what the codex says:
 http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_comment_approved

 This is the code:
 {{{
 function check_for_spam( $approved, $commentdata ) {
         if( !empty( $commentdata['comment_author_url'] ) ) {
                 return 0; // disapproved
         }
         return $approved;
 }
 add_filter('pre_comment_approved', 'check_for_spam', '99', 2);
 }}}

 Tested in WP 3.8.1, 2012 theme.

 This code is in functions.php and when I add a comment with a URL filled
 in the comment makes it into the database and I receive a "Please
 moderate" e-mail.
 I would think a return of 0 means that the comment is ignored, no e-mail
 is sent and it certainly is not in the database. Or am I wrong??

 If I return 'spam' in stead of 0 everything works as expected. There is no
 e-mail and the comment is stored in the database, and can be found in the
 spam bin when in admin.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27140>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list