I am writing a media plugin that uses custom tables to store its contents. (eg not the post tables where wordpress stores it attachment data). Now i’m looking for a way to use the default wordpress comment system to add comments to it. (These comments will not be in the regular comment table but also a custom table.
I need two things:
- A hook that allows me to intercept
the comment submit and process it
with my own code if criteria are
met. The criteria itself is
arbitrary and not important, just
need a way to get to the post data
before WordPress processes it. - A filter that allows me to replace the wp_list_comments() data with my own tabledata.
It’s a hacky idea, I know, but the post/attachment table is too limiting for what I need.
Any ideas?
wp_list_comments()
has no filters or hooks so its going to be a bit hard, what you can do is usecomments_array
filter hookand as for “intercept the comment submit and process” chips answer would be the best way using
preprocess_comment
filter hook but you want be able to avoid WordPress form inserting the comment to the default table as well, so you can usewp_insert_comment
action hook to remove the comment from the default table right after its inserted:Try using the
preprocess_comment
filter hook, e.g.