Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save petertwise/14820ddc5a111e7f672ee93537599689 to your computer and use it in GitHub Desktop.
Save petertwise/14820ddc5a111e7f672ee93537599689 to your computer and use it in GitHub Desktop.
OOPSpam Skip Certain User Roles
<?php
add_filter( 'oopspam_check_for_spam', 'logged_in_active_subscribers_skip_oopspam_check', 99 );
function logged_in_active_subscribers_skip_oopspam_check() {
// if the user has active-subscriber role, pass the check automatically
// https://wordpress.stackexchange.com/a/5048/41488
$user = wp_get_current_user();
if ( $user && isset( $user->roles ) && in_array( 'active-subscriber', (array) $user->roles ) ) {
return 0; // zero spam score means "never block due to being spam"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment