Serenade Posted February 13, 2015 Share Posted February 13, 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...
Digvijay Posted February 13, 2015 Share Posted February 13, 2015 Here is the modified hook .To make it work all you need to do is set a product custom field with name Check For valid IP in the products that you want this hook to apply to. You can change the name for sure. You can set this field to admin only. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function checkIPIsValid($vars) { //Get all products that has Custom field $customfieldname = "Check For valid IP"; $products = get_query_val('tblcustomfields', 'GROUP_CONCAT(relid)', array('fieldname' => $customfieldname, 'type' => 'product')); if (!empty($products)) { $productcondition = " AND tblproducts.id IN ($products)"; } else { $productcondition = ''; } $result = full_query("SELECT tblorders.id FROM tblorders JOIN tblhosting ON (tblorders.id=tblhosting.orderid) JOIN tblproducts ON (tblhosting.packageid=tblproducts.id) WHERE tblorders.ipaddress='" . $_SERVER['REMOTE_ADDR'] . "' $productcondition"); 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 15, 2015 Author Share Posted March 15, 2015 Hey! Sorry for the super late reply, I totally forgot about this post. Anyway, I tried the script but it does not seem to work. I have added the custom field to all products I wanted to limit, but it appears to be limiting all products on all orders... 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.