function validate_referrer()
{
global $bp;
global $wpdb;
$referrer = $_POST['field_3'];
$members = $wpdb->get_var("SELECT * FROM wp_users WHERE user_login = '$referrer'");
if (!$members) {$bp->signup->errors['field_3'] = __('Please enter the correct referrer','buddypress');}
}
add_action('bp_signup_validate', 'validate_referrer');