Hello,
Is it possible to invalidate email address with spaces during buddypress registration. after invalidating it an error message like this should be displayed (Sorry, this email is invalid. Please choose another. Email addresses cannot contain spaces.)
The problem is my site only enables login by email and password. but when some users register they mistakenly leave a space after their email and buddypress accepts their registration.
Now after registering and the users are trying to login with the correct email and password but their login fails not knowing that they added a space after their email during registration.
Thanks
Please note that i’m not reffering to spaces in between the email address but after the email address for example
abcdef@gmail.com 
  refers to the space added
This problem mainly occurs when a user is registering on a mobile phone and add their email address from google saved email address suggestion after selecting the suggested email a space is added automatically without the user realising this and buddypress accepts the registration with the space after the email.
Hi Tosin,
Are you using anything to override the validation or signup process?Otherwise, BuddyPress will strip down any space at the end (It is WordPress that strips it in sanitize_email).
It is not a BuddyPress issue, Most probably some code or plugin causing it.
Regards
BrajeshI just deactivated all plugins and noticed that its a login problem and not registration issue wordpress is not allowing logins with spaces after the email address. The error message (invalid email) is being displayed. Will it be possible to display a custom error message in the login form when a user mistakenly adds a space after their email address during login. The custom error message should be (Sorry, this email is invalid. Email addresses cannot contain spaces.) Since the space is invisible the user still thinks that their email address is correct but this custom error message will point out the cause of login failure.
I am also using the branded login plugin
I also noticed that this email login issue also occured in the default wordpress login page @ (wp-login.php) after deactivating the branded login plugin.
Now will it be possible to validate logins with emails and usernames that have spaces at the back in the login form
After further investigations i’ve found the culprit code below
/** * Email login support for bp-branded-login plugin */ add_filter( 'wp_authenticate_user', function( $user ) { if ( isset( $_POST['log'] ) && ! is_email( $_POST['log'] ) ) { return new WP_Error( 'invalid_email' ); } return $user; }, 10 );
Please can this be improved to prevent invalidation of email addresses with spaces at the back
Thanks
Hello Tosin,
Please try the following code and let me know if works or not
/** * Email login support for bp-branded-login plugin */ add_filter( 'wp_authenticate_user', function( $user ) { if ( isset( $_POST['log'] ) && ! is_email( trim( $_POST['log'] ) ) ) { return new WP_Error( 'invalid_email', __( 'Please provide a valid email' ) ); } return $user; }, 10 );
Regards
Ravi
You must be logged in to reply to this topic.