I have custom code that handles comment insertions using wp_insert_comment
. Does Akismet plugin
expose any hooks, functions, class that can work with the same and possibly elsewhere where custom forms for user content submissions are involved? Or do I need to write custom code to make calls to Akismet API?
1 Answer
I grep
ed a slightly aging copy of the Akismet plugin and these are the hooks I found– filters first, then actions.
admin.php:374: if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) { akismet.php:144: $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua ); akismet.php:201: if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) akismet.php:336: $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); akismet.php:391: if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) akismet.php:439: if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number akismet.php:448: $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 ); akismet.php:472: if ( apply_filters( 'akismet_optimize_table', ( $n == 11 ), 'commentmeta' ) ) { // lucky number akismet.php:586:$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); admin.php:548: do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]); admin.php:599: do_action('akismet_submit_spam_comment', $comment_id, $response[1]); admin.php:740: do_action( 'comment_remove_author_url' ); admin.php:755: do_action( 'comment_add_author_url' ); akismet.php:376: do_action( 'akismet_comment_check_response', $response ); akismet.php:383: do_action( 'akismet_spam_caught' ); akismet.php:434: do_action( 'delete_comment', $comment_ids ); legacy.php:85: do_action( 'delete_comment', $comment_ids ); legacy.php:222:do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
As you can see, a number of those specifically reference comments though I don’t know exactly what you need to do. As far as other “user content submissions are involved”, again, I don’t know what exactly you need to do.
I would make a suggestion though. Rather than looking for hooks, which may or may not be present for what you need, look at the various functions provided by the Akismet plugin. Some of those functions, for example akismet_http_post()
, provide pretty convenient access to the Akismet API, at least that is how it looks to me.