Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#18064 closed enhancement (worksforme)

Adding a hook for specific comment types

Reported by: joostdevalk's profile joostdevalk Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Comments Keywords: has-patch dev-feedback
Focuses: Cc:

Description

Right now there's no way to hook an action only for specific comment types, resulting in the issue that each plugin that hooks in almost always need to do get_comment, because it need to get the comment type.

Attachments (1)

comment-insert.diff (437 bytes) - added by joostdevalk 14 years ago.
Proposal patch

Download all attachments as: .zip

Change History (3)

@joostdevalk
14 years ago

Proposal patch

#1 @scribu
14 years ago

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

Instead of using get_comment(), you receive the comment object as the second argument:

function my_test_callback( $comment_id, $comment ) {
  if ( 'foo' == $comment->comment_type ) {
    // do stuff here
  }
}
add_action('wp_insert_comment', 'my_test_callback', 10, 2);

Therefore, there is really no need for an additional action there.

#2 @joostdevalk
14 years ago

Ah darn, the plugin i was looking at hooked into post_comment but that's a rather stupid action to hook into then indeed. Thx!

Note: See TracTickets for help on using tickets.