0

i am using Comment Whitelist plugin to create a whitelist of email domains for autoapporing comments. It seems that the plugin overrides wordpress : Settings->Discussion options->moderation blacklist. My settings are here .

The plugin works as expected,autoapproving comments from a whitelist of domains. But i would like to include also to it the protection from spam that WordPress offers with wp_check_comment_disallowed_list()

The main idea inside the plugin is

function comment_whitelist__pre_comment_approved( $approved ) {
    global $wpdb, $current_user;
    
    // Si esta aprobado ...
    if ( $approved == '1' ) {
        
        // Pues sigue aprobado!! ;-))
        return $approved;
    }else{
        
        $mod_keys = trim( get_option('whitelist_keys') );
        
        // Si no tengo lista blanca ...
        if ( empty($mod_keys) ) {
            // Devuelvo lo que tenia!!
            return $approved;
        }else{
            
            // Continuo probando...
            $words = explode("\n", $mod_keys );
            // Si no tenemos elementos ...
            if ( !sizeof($words) ) {
                // Devolvemos lo que nos habia llegado de origen
                return $approved;
            }else{
                
                // Revisamos cada entrada de la lista blanca
                foreach ( (array) $words as $word ) {
                    $word = trim($word);
                    
                    // Skip empty lines
                    if ( empty($word) ) { continue; }
                    
                    // Do some escaping magic so that '#' chars in the
                    // spam words don't break things:
                    $word = preg_quote($word, '#');
                    
                    $pattern = "#$word#i";
                    if ( preg_match($pattern, $_REQUEST['email']) ) {
                        // Esta incluido en la lista blanca, nos da igual, le aprobamos.
                        return '1';
                    }
                }
                
                // NO Esta incluido en la lista blanca, le moderamos si no lo estaba, si es SPAM le dejamos.
                return ( $approved == '1' ) ? '0' : $approved;
                
            }
        }
    }
    
    die('fin');
    return $approved;
}
add_filter('pre_comment_approved', 'comment_whitelist__pre_comment_approved');

How could i also include the wp_check_comment_disallowed_list() hook so that i can still keep comments in moderation if spam words are included in the comment?

I have tried to set to the plugins filter priority 11 , but this didn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.