Serenade Posted March 25, 2015 Share Posted March 25, 2015 I found this hook to limit one account per IP. It works perfectly, except I would like to limit it only to specific products (pid=1, and pid=2). If anyone has any ideas and are willing to help it'd be greatly appreciated! <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function checkIPIsValid($vars) { $result = select_query("tblorders","id",array("ipaddress"=>$_SERVER['REMOTE_ADDR'])); if (mysql_num_rows($result) != 0) { return "It looks like your IP has already been used to register an account."; } } add_hook("ClientDetailsValidation",1,"checkIPIsValid"); ?> 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 26, 2015 Share Posted March 26, 2015 if the above code work for then this modification will do too, <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function checkIPIsValid($vars) { $result = full_query("SELECT `tblorders`.`userid` FROM `tblorders`,`tblhosting` WHERE `tblorders`.`ipaddress`='".addslashes($_SERVER['REMOTE_ADDR'])."' AND `tblorders`.`id`=`tblhosting`.`orderid` AND `tblhosting`.`packageid` IN (1,2)"); if (mysql_num_rows($result) != 0) { return "It looks like your IP has already been used to register an account."; } } add_hook("ClientDetailsValidation",1,"checkIPIsValid"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Serenade Posted March 28, 2015 Author Share Posted March 28, 2015 (edited) Thanks for the quick reply! It looks like the hook is properly checking if the IP exists, however it seems the hook is limiting all of my Products IDs and not just 1 and 2. I only want the hook to stop if the order is for Product 1 or 2. If the order is product 3 or anything else, the order should proceed. Thanks a lot! if the above code work for then this modification will do too, <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function checkIPIsValid($vars) { $result = full_query("SELECT `tblorders`.`userid` FROM `tblorders`,`tblhosting` WHERE `tblorders`.`ipaddress`='".addslashes($_SERVER['REMOTE_ADDR'])."' AND `tblorders`.`id`=`tblhosting`.`orderid` AND `tblhosting`.`packageid` IN (1,2)"); if (mysql_num_rows($result) != 0) { return "It looks like your IP has already been used to register an account."; } } add_hook("ClientDetailsValidation",1,"checkIPIsValid"); ?> Edited March 28, 2015 by Serenade Typo 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.