Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#19860 closed defect (bug) (invalid)

pre_comment_approved filter has second argument undefined

Reported by: laotse Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


I wrote a filter:

function tgb_comment_filter_approved($mApproved, $aCommentData){ ... }
add_filter('pre_comment_approved', 'tgb_comment_filter_approved');

and $aCommentData is always undefined. So effectively the changeset 15592 fixing #14802 does not work.

Change History (1)

#1 @dd32
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

You must specifically add the filter asking for 2 arguements to be passed.:

add_filter($action, $function, $priority=10, $number_of_args=1);

So you want:

add_filter('pre_comment_approved', 'tgb_comment_filter_approved', 10, 2);

Note: See TracTickets for help on using tickets.