Skip to content

Forum in maintenance, we will back soon 🙂

Those pesky i.t.s.m...
 
Notifications
Clear all

Those pesky i.t.s.m.e.@gmail.com user registrations

3 Posts
2 Users
5 Reactions
115 Views
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
Topic starter
 

Here is a code snippet to stop emails with more than 2 '.' in the user part of the email address. Adjust the 2 or add more conditions as you see fit.

function validate_email_on_registration($errors, $sanitized_user_login, $user_email) {
	$INV = 'invalid_email';
	$MSG = __('<strong>ERROR</strong>: Invalid email address.');
	if (is_email($user_email)) {
		$user = explode('@', $user_email)[0];
		$uparts = explode('.', $user);
		if (count($uparts) > 2) {
			$errors->add($INV, $MSG);
		}
	}
    return $errors;
}
add_filter('registration_errors', 'validate_email_on_registration', 10, 3);

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 05/02/2024 1:14 pm
Hasan Aboul Hasan
(@admin)
Posts: 1251
Member Admin
 

Thanks for sharing. In your experience, are these emails spammy?

 
Posted : 05/02/2024 4:24 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
Topic starter
 

@admin yes they're spammish and many aren't deliverable because the accounts get removed before they can get the confirmation email to make the password change. In the case of gmail you can add as many periods as you want in the name portion of the email because their server removes all of them so no matter how you format the name portion it is always deliverable to your account. This is true even if you register your gmail account with a period, gmail will remove the period on the server side.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 05/02/2024 5:36 pm
Share:
build ai agents ad