[wp-hackers] Comment Hook
Mark Jaquith
mark.wordpress at txfx.net
Fri Nov 12 13:24:28 UTC 2004
If you want to put a comment into moderation, in 1.2 or 1.2.1, you have
to retroactively do it. Meaning, you let the comment post, and then you
hook in at comment_post and if you need to moderate it, just change the
status in the database. MooKitty's Friendly Comments plugin does that:
http://mookitty.co.uk/devblog/archives/2004/06/22/kittens-friendly-comments-10/
The problem there is that the "comment posted!" e-mail already got sent out.
Alternatively, instead of hooking in... you can have the code be
directly executed when the plugin is included, and wrap it in a
conditional that looks for the $_POST variables that are set when a
comment is being posted.
Here's what MooKitty uses in her Spaminator plugin:
if ( !empty($_POST['comment']) && !empty($_POST['comment_post_ID']) &&
!is_array($_POST['comment']) ) {
// code, functions, whatever, goes here
}
Of course, you'd basically have to place the entire wp-comments-post.php
file in the plugin to have any control over moderation or comment post.
Basically, in WP 1.2.x, there is no way to hook in to the comment
moderation process. There is a hook before... but you can't affect
anything, and there is a hook after, but by then, the e-mail has aready
gone out and the comment has been posted. So really, you have to either
deal with the e-mail that is sent, or hijack the process entirely.
Or... wait for 1.3 which, by the way, is quite stable now... I've been
running my blog on it for months.
Ammar Ibrahim wrote:
> There's another way, I can hack the file 'wp-comments_post.php' but
> that would make it hard for other people to use the plugin. Anyway,
> When will 1.3 be stable?
>
> Ammar
>
> Mark Jaquith wrote:
>
>> If it's WP 1.2 or 1.2.1, you can't. In WP 1.3, declare $approved
>> global for the function and set $approved = 0;
>
>
>
>
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
>
>
>
More information about the hackers
mailing list