Make WordPress Core

Opened 14 years ago

Closed 9 years ago

#12431 closed enhancement (fixed)

Record comment meta in wp_new_comment

Reported by: tellyworth's profile tellyworth Owned by: boonebgorges's profile boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.0
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

Spam filter plugins usually trigger on the preprocess_comment filter, which obviously happens prior to storing the comment (and thus prior to knowing comment_ID).

Comment meta would be ideal for storing spam status information, but since the comment_ID isn't known at that point, doing so involves jumping through some hoops.

This patch provides a simple way for spam filters to include comment metadata from preprocess_comment. They simply include values in a 'comment_meta' array like this:

add_action('preprocess_comment', 'my_spam_handler');

function my_spam_handler($comment) {
    $comment['comment_meta']['my_spam_status'] = 'not-spam';
    return $comment;
}

Each key/value pair in the comment_meta array is stored as comment metadata.

Attachments (2)

preprocess-comment-meta-r13514.patch (695 bytes) - added by tellyworth 14 years ago.
12431.diff (1.3 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (7)

#1 @Denis-de-Bernardy
14 years ago

  • Milestone changed from Unassigned to 3.1

#2 @nacin
13 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Triage to Future Release

#3 @chriscct7
9 years ago

  • Keywords dev-feedback added

Needs to be re-reviewed for inclusion.

@wonderboymusic
9 years ago

#4 @wonderboymusic
9 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Future Release to 4.4
  • Owner set to boonebgorges
  • Status changed from new to assigned

12431.diff works, does it in wp_insert_post()

#5 @boonebgorges
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34533:

Allow metadata to be attached to comment at time of creation.

The new $comment_meta parameter of wp_insert_comment() allows an array of
key/value pairs to be passed when creating a comment. These pairs are then
stored as commentmeta when the comment has been created.

Props tellyworth, wonderboymusic.
Fixes #12431.

Note: See TracTickets for help on using tickets.