Skip Akismet Checks for Trusted Logged-In Users
Stops sending comments from logged-in users who can edit posts (authors, editors, administrators) to Akismet, saving API calls and keeping staff replies out of the spam queue.
Opens WPIDE on
Code
add_filter( 'preprocess_comment', function ( $commentdata ) {
if ( class_exists( 'Akismet' ) && is_user_logged_in() && current_user_can( 'edit_posts' ) ) {
remove_filter( 'preprocess_comment', array( 'Akismet', 'auto_check_comment' ), 1 );
}
return $commentdata;
}, 0 );
Notes
Change edit_posts to moderate_comments to trust only moderators and administrators.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.