WordPress MU

Changeset 1640


Ignore:
Timestamp:
01/28/2009 02:43:49 PM (18 years ago)
Author:
donncha
Message:

Added "is_user_spammy()"
Check that user is not a spammer when logging in. fixes #798

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wpmu-functions.php

    r1639 r1640  
    20852085}
    20862086
     2087function is_user_spammy( $username = 0 ) {
     2088        if( $username == 0 ) {
     2089                global $current_user;
     2090                $user_id = $current_user->ID;
     2091        } else {
     2092                $user_id = get_user_id_from_string( $username );
     2093        }
     2094        $u = new WP_User( $user_id );
     2095        if( $u->spam == 1 )
     2096                return true;
     2097        return false;
     2098}
     2099
     2100function login_spam_check( $user, $password ) {
     2101        if( is_user_spammy( $user->id ) )
     2102                return new WP_Error('invalid_username', __('<strong>ERROR</strong>: your account has been marked as a spammer.'));
     2103        return $user;
     2104}
     2105add_action( 'wp_authenticate_user', 'login_spam_check', 10, 2 );
     2106
    20872107// Load WordPress Admin Bar plugin by Viper007Bond. http://www.viper007bond.com/wordpress-plugins/wordpress-admin-bar/
    20882108include( ABSPATH . WPINC . '/wordpress-admin-bar/wordpress-admin-bar.php' );
Note: See TracChangeset for help on using the changeset viewer.