How do I hook into the WordPress login system to stop some users programmatically?

Solution:1

You can either overload the wp_authenticate function (see the function in the code here: http://core.trac.wordpress.org/browser/trunk/wp-includes/pluggable.php) and return a WP_error if you don’t want to allow the user to login.

Or better, use the filter authenticate and return null if you don’t want the user to log in, e.g.

add_filter('authenticate', 'check_login', 10, 3);
function check_login($user, $username, $password) {
    $user = get_userdatabylogin($username); 

    if( /* check to see if user is allowed */ ) {
        return null;
    }
    return $user;
}

Solution:2

Use following code

add_filter( 'authenticate', 'chk_active_user',100,2);
function chk_active_user ($user,$username) 
   {
     $user_data = $user->data;
     $user_id = $user_data->ID;
     $user_sts = get_user_meta($user_id,"user_active_status",true);
     if ($user_sts==="no")
     {
        return new WP_Error( 'disabled_account','this account is disabled');

      }
      else
      {
       return $user;
      }
        return $user;
     }