Jump to content

Need Help. Allow registration from gmail.com and yahhoo.com only,


Cotlas

Recommended Posts

Hi, can anyone help me to add this validation code in whmcs clientregister.tpl. This is a wordpress function code which i was using in wordpress theme. I want to add this in whmcs also, Because I m geting fake registrations from fake domain emails. like fakeemail@abcd.com, I have used email domain ban feature in sucurity tab but its not working. and fake users use new domain everytime. So I want my users to register from only allowed email domains. Please help

 

Here is the code.

function is_valid_email_domain($login, $clientemail, $errors ){
 $valid_email_domains = array("gmail.com","yahoo.com");// whitelist email domain lists
 $valid = false;
 foreach( $valid_email_domains as $d ){
 $d_length = strlen( $d );
 $current_email_domain = strtolower( substr( $clientemail, -($d_length), $d_length));
 if( $current_email_domain == strtolower($d) ){
 $valid = true;
 break;
 }
 }
 // if invalid, return error message
 if( $valid === false ){
 $errors->add('domain_whitelist_error',__( '<strong>ERROR</strong>: you can only register using @gmail.com or @yahoo.com emails' ));
 }
}
add_action('register_post', 'is_valid_email_domain',10,3 );

 

Link to comment
Share on other sites

  • 5 years later...

This task can't be done by modifying clientregister.tpl, but it must be done using the hook ClientDetailsValidation ( https://developers.whmcs.com/hooks-reference/client/#clientdetailsvalidation )

(a plus using this hook: it prevent the user not only from registering using unwanted data, but also from modifying them later after the registration)

Here you have a hook to check various customer data, to prevent fraudulent registrations: it checks email addresses (in order not to allow registration using disposable email addresses) and it checks other fields, in order to block the usage of special characters (to prevent injections)

You can easily modify it in order to accept only particular email addresses  

https://domainregister.international/index.php/knowledgebase/696/Check-User-Data-for-Better-WHMCS-Security.html

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