Last active
September 15, 2024 19:21
-
-
Save petertwise/14820ddc5a111e7f672ee93537599689 to your computer and use it in GitHub Desktop.
OOPSpam Skip Certain User Roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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