Jump to content

Limiting Sign-Ups to Trusted Email Services


Looper
Go to solution Solved by Remitur,

Recommended Posts

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

image.png.8724967c313e49fcb9726bf24d440c7c.png

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 by Looper
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated