Jafar Muhammed Posted April 17, 2019 Share Posted April 17, 2019 Hello, I wish to block free domain name extensions like .tk. When people are trying to place an order with .tk or similar TLDs, the system must not allow them to use those domains. Is there any way to accomplish this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 17, 2019 Share Posted April 17, 2019 HI Jafar, 4 hours ago, Jafar Muhammed said: I wish to block free domain name extensions like .tk. When people are trying to place an order with .tk or similar TLDs, the system must not allow them to use those domains. Is there any way to accomplish this? if you wanted to block specific domains, e.g gmail.com, from signing up, then you could have used the Banned Email Domains option... https://docs.whmcs.com/Security/Ban_Control#Banning_Email_Domains Quote With WHMCS it is possible to ban email domains from signing up. This is useful if you want to block customers signing up using free email accounts. To enable this feature, simply go to Setup > Other > Manage Banned Emails. You will then see a list of all the currently banned email domains and the number of times a customer has attempted to signup using them. To add a new banned email domain, click the Add tab at the top of the page and then enter the email domain you wish to ban, for example "hotmail.com". but you effectively want to use a wildcard domain (e.g the client might be using mail@jafar.tk or mail@brian.tk) and I doubt the above feature would support that. I suspect that you would have to use a client validation hook and display an error message if someone tries to register using a .tk email address... <?php # Block .tk Email Addresses From Registering Hook # Written by brian! add_hook('ClientDetailsValidation', 1, function($vars) { if (substr($vars['email'], -3) == '.tk') { return Lang::trans('clientareaerroremailinvalid'); } }); so this basic hook will return the above error string (in the user's current language) if they try to use a .tk address and the registration will not progress until they use a valid email address. you can easily change the hook to use another language string, or hard-code the error reply instead (e.g if your site only uses one language and you want to warn them specifically about using .tk domains), or even expand the hook to block other TLDs or domains. 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 17, 2019 Author Share Posted April 17, 2019 Hello @brian! I am not about blocking email addresses with disposable domain names for signing up. I used to get people to sign up, for example.tk, for example.cf etc. In the Cart page when someone places an order for a shared hosting account, they shouldn't be able to place an order for such free domain names. Do we have any workaround for that? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 17, 2019 Share Posted April 17, 2019 (edited) There's a way but... 36 minutes ago, Jafar Muhammed said: they shouldn't be able to place an order for such free domain names. Just why? 🤔 You sold an hosting package. What's the problem in using .tk domains? They cause no harm. If you block .tk domains these people won't be able to place an order with you therefore you are willing to lose money for no apparent reason. Edited April 17, 2019 by Kian 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 17, 2019 Author Share Posted April 17, 2019 These are disposable domain names. People register this for free, and after a few weeks, Freenom will remove the domain name. Most of these customers are indeed first time customers, and they don't have much knowledge about how domains and hosting accounts works. When Freenom terminates their free domains, these people first assume that it is an issue with my service. Most of the time, the people who are only looking for free or cheap service will be tough to convert as a paying customer. So technically for me at least, it is a waste of my resources. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 17, 2019 Share Posted April 17, 2019 Instead of preventing them from using .tk domains and lose money, why don't you just show them an alert where you explain that .tk domains last for a very limited amount of time and that it's not your fault if the website stops working. You could even encourage them to register a more serious TLD. You could show this message as soon as they add the .tk domain. 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 17, 2019 Author Share Posted April 17, 2019 That's an excellent option, @Kian. But I don't know how to do that? Could you please give me some insight about the way to achieve this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 17, 2019 Share Posted April 17, 2019 do you sell/offer .tk domains as a domain registration / transfer option? 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 17, 2019 Author Share Posted April 17, 2019 Nope @brian! Not just .tk, I want to block all the free TLDs which Freenom offers. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 17, 2019 Share Posted April 17, 2019 I'm guessing you want to block the service domain from being a .tk domain and not like the customer's contact info. As such this hook should do the trick: add_hook('ShoppingCartValidateDomain', 1, function($vars) { if ($vars['tld'] === '.tk') return array(".tk Domains are not accepted for services. "); else return false; // validates }); Though on testing it doesn't return the error but some generic error and tried it with a string and array as docs say it takes both. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 17, 2019 Share Posted April 17, 2019 3 hours ago, Jafar Muhammed said: Nope @brian! Not just .tk, I want to block all the free TLDs which Freenom offers. In that case, check this hook would be better as you can add the TLDs to the array instead of duplicating: add_hook('ShoppingCartValidateDomain', 1, function($vars) { $BlockedTLDS = array('.tk','.free','.nomies','.mmmm'); if (in_array( $vars['tld'], $BlockedTLDS)) return array(".tk Domains are not accepted for services. "); else return false; }); 1 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 17, 2019 Share Posted April 17, 2019 (edited) The problem is that ShoppingCartValidateDomain doesn't work 😀 Not with standard cart. It only works on discontinued orderform templates like Modern. It's a known issue. I don't know if it works with the latest version of WHMCS. For sure it doesn't on 7.6.1 (can't try on newer WHMCS atm). Edited April 17, 2019 by Kian 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 18, 2019 Share Posted April 18, 2019 Right that was the behavior I had mentioned above. So it generally works, but the error display doesn't. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 18, 2019 Share Posted April 18, 2019 On 17/04/2019 at 18:41, Jafar Muhammed said: Nope @brian! Not just .tk, I want to block all the free TLDs which Freenom offers. ok - if you were, then removing them (or at least not setting a price) from your domain pricing would have removed them as registration/transfer options for products and would have left you with only "use existing domain" option to take care of. in the absence of the ShoppingCartValidateDomain hook not responding correctly (which has been known about for at least 6 months by WHMCS and was why I didn't suggest it), there are a few other options... you could validate it at checkout with a hook, but that's not really practical as it's too late by then to send them back to choose another domain... you could use a html5 pattern in the template, but as they're case sensitive, you'd need to cover all permutations of cf, ga, gq, ml and tk - doable, but again not really practical. you could use a footer hook to disallow these TLDs using jQuery - e.g so that if someone enters .tk (.cf or whatever), it removes it from the TLD field and the user will have to enter another TLD (or you can make it show an INVALID error in the TLD form field itself)... i'm not sure if you can easily show an error similar to the patterns output though... I suppose you could use Language Overrides to change the "I will use my existing domain and update my nameservers" string to tell the users that these TLDs will be blocked. 1 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 18, 2019 Author Share Posted April 18, 2019 1 hour ago, brian! said: I suppose you could use Language Overrides to change the "I will use my existing domain and update my nameservers" string to tell the users that these TLDs will be blocked. This seems an easy fix. I will give a try. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 19, 2019 Share Posted April 19, 2019 14 hours ago, Jafar Muhammed said: This seems an easy fix. I will give a try. it's not really a fix - it's more like a warning outside a shop not to steal... it might make some users think, but it won't stop the the naughty ones! 👮♂️ try it alongside the attached hook - it should prevent users trying to add any free freenom TLD as an existing domain option... block_freenom.php 1 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 21, 2019 Author Share Posted April 21, 2019 Hey @brian! Your Hooks blocks them! Interestingly, I found one thing, m cart accepts .tk. And when I try .ml, .ga, .cf, .gq, I get Invalid domain name provided error. Screenshot https://prnt.sc/nev8xy I switched between ResellerClub and WHMCS Name Spinning as my Lookup Provider. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 21, 2019 Share Posted April 21, 2019 4 minutes ago, Jafar Muhammed said: Interestingly, I found one thing, m cart accepts .tk. that implies the hook isn't working, because if it was, the field would be emptied. 7 minutes ago, Jafar Muhammed said: And when I try .ml, .ga, .cf, .gq, I get Invalid domain name provided error. Screenshot https://prnt.sc/nev8xy I switched between ResellerClub and WHMCS Name Spinning as my Lookup Provider. almost certainly, resellerclub and Namespinning (which is eNom) won't sell these free TLDs, so WHMCS will revert to using the whois server entries for these TLD checks... there is an entry for .tk, but not for the others... I did consider suggesting removing .tk from the whois list, but it's not a foolproof solution. the fact it gives that error is a long-standing bug... WHMCS has for years often shown the wrong error messages in the cart... e.g the error message bears no relation to the actual error. 🙄 1 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted April 21, 2019 Author Share Posted April 21, 2019 2 minutes ago, brian! said: that implies the hook isn't working, because if it was, the field would be emptied. It is working. I tried this after disabling the hook. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 21, 2019 Share Posted April 21, 2019 Just now, Jafar Muhammed said: It is working. I tried this after disabling the hook. oh ok! 🙂 1 Quote Link to comment Share on other sites More sharing options...
Hellerkeller Posted April 23, 2019 Share Posted April 23, 2019 The .tk extension is not good according to my knowledge it's not universal. https://www.rfpgurus.com/ 0 Quote Link to comment Share on other sites More sharing options...
dbbrito Posted March 9, 2023 Share Posted March 9, 2023 Friends, is it possible to modify this hook to block the customer from registering, making a purchase or changing personal data with gmail and hotmail emails? Thanks 0 Quote Link to comment Share on other sites More sharing options...
atonalwilson Posted March 18, 2023 Share Posted March 18, 2023 Hello, The document referenced in the previous post offers instructions on how to prevent cPanel users from creating certain domain names as addon domains or aliases but does not apply to new account creations in Web Host Manager. I encourage you to open a feature request if you'd like to see an option that prevents resellers from creating certain domain extensions as new accounts. Thanks 0 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.