Looper Posted November 21, 2023 Share Posted November 21, 2023 Many people are using temporary email addresses to sign up on my website. I want to stop this and only allow well-known email services like Gmail, Yahoo, and Outlook. How can I do that? 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted November 21, 2023 Share Posted November 21, 2023 The following hook will do the trick (will also run when a client tries to update their email later on) <?php declare(strict_types=1); add_hook('ClientDetailsValidation', 1, function ($params) { $allowedProviders = [ 'gmail.com', 'outlook.com', 'hotmail.com', 'icloud.com', ]; $explodedEmail = array_filter(explode('@', $params['email'])); $emailProvider = $explodedEmail[1]; if (!in_array($emailProvider, $allowedProviders, true)) { return 'Sorry, your email address provider is not whitelisted. Please choose another.'; } }); Won't work for user emails though, and WHMCS doesn't seem to hook on to that annoyingly. 0 Quote Link to comment Share on other sites More sharing options...
Looper Posted November 22, 2023 Author Share Posted November 22, 2023 5 hours ago, leemahoney3 said: The following hook will do the trick I'm new to this. Could you please provide guidance on how to create this hook and where to add it? 0 Quote Link to comment Share on other sites More sharing options...
Solution Remitur Posted November 22, 2023 Solution Share Posted November 22, 2023 Look at this hook: it doesn't limit the registration to whitelisted domains, but prevent the usage of disposable addresses: https://domainregister.international/index.php/knowledgebase/696/Check-User-Data-for-Better-WHMCS-Security.html 1 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted November 22, 2023 Share Posted November 22, 2023 1 hour ago, Remitur said: Look at this hook: it doesn't limit the registration to whitelisted domains, but prevent the usage of disposable addresses: https://domainregister.international/index.php/knowledgebase/696/Check-User-Data-for-Better-WHMCS-Security.html That relies on a call to a third party. If that's what the OP wants, then cool. 20 hours ago, Looper said: I'm new to this. Could you please provide guidance on how to create this hook and where to add it? Just create a PHP file in [YOUR WHMCS ROOT]/includes/hooks (e.g. RestrictClientEmailHosts.php) 1 Quote Link to comment Share on other sites More sharing options...
Looper Posted November 23, 2023 Author Share Posted November 23, 2023 (edited) 7 hours ago, Remitur said: Look at this hook: it doesn't limit the registration to whitelisted domains, but prevent the usage of disposable addresses: https://domainregister.international/index.php/knowledgebase/696/Check-User-Data-for-Better-WHMCS-Security.html Thanks, man! It worked like a charm! It also checks if someone has used special characters in the name, address, or city. 5 hours ago, leemahoney3 said: Just create a PHP file in [YOUR WHMCS ROOT]/includes/hooks (e.g. RestrictClientEmailHosts.php) Thank you! It started working right out of the box when I placed the PHP file in the hook directory. Edited November 23, 2023 by Looper 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.