Jump to content
Sign in to follow this  
Kian

Client to Group based on Registered Domains

Recommended Posts

The hook assigns clients to groups based on the number of active domains in their accounts (Active, Grace and Redemption). This is particularly useful for Domain Pricing slabs. Let's take this code as example.

$groups['1'] = '10';
$groups['2'] = '25';
$groups['3'] = '100';

The key of $groups array (eg. ['1']) represents the ID of the group while the value the number of active domains. According to the above configuration, here is what happens:

  • Customer A has 10 domains. He goes to client group ID 2. Next day domains become 9. The the customer is removed from the group
  • Customer B has 99 domains. He still goes to client group ID 2 but will be moved to 3 in case he manages to reach 100 domains
  • Customer C has 250 domains. Group ID 3

The hook runs with WHMCS daily cron job meaning that customers are moved (or removed) from groups on a daily basis. Optionally, you can use the following feature to add some restrictions:

  • $activeCustomers rules apply only on Active customers (boolean true or false)

Get the Code »

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Similar Content

    • By Troy
      If you use a supported registrar, WHMCS' Registrar TLD Sync can keep your domain pricing up to date without a lot of effort. However, it does NOT sync the pricing to your existing clients' domains. The Bulk Pricing Updater isn't suited to this task either, requiring many steps to update pricing for different TLDs, billing cycles and domain addons.
      I put together a SQL query that will set the recurring amount of all client domain names in tbldomains with your current domain pricing, and figured I'd share it for those whom it might benefit.
      This was written for WHMCS 8.1.3 and MariaDB 10.3. I recommend testing it on a copy of your data, and I make no warranties regarding it's suitability to your particular environment, nor claim that it is free of error. That said, it works well for me.
      Here are some suggestions for testing this on a copy of your data, assuming you have access to the server shell as root:
      1. Export a copy of the relevant tables and import into a work database:
      mysqldump <your-whmcs-db-name> tblclients tbldomains tbldomainpricing tblpricing > ~/workdb.sql mysqladmin create workdb mysql workdb < ~/workdb.sql 2. Get an idea of the current recurring amount for all your active domains (to give you something to compare against after running the sql script):
      mysql workdb MariaDB [workdb]> select sum(recurringamount) from tbldomains where status = 'Active'; +----------------------+ | sum(recurringamount) | +----------------------+ | 50029.21 | +----------------------+ 1 row in set (0.000 sec) 3. Create a file to hold the SQL that you can run against the database:
      nano ~/domain_pricing_sync.sql The SQL to put in the file:
      SET @idp = (select ssetupfee from tblpricing where type = 'domainaddons'); SET @dns = (select msetupfee from tblpricing where type = 'domainaddons'); SET @fwd = (select qsetupfee from tblpricing where type = 'domainaddons'); update tbldomains d, tbldomainpricing dp, tblpricing p, tblclients c set d.recurringamount = case d.registrationperiod when 1 then p.msetupfee + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 2 then p.qsetupfee + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 3 then p.ssetupfee + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 4 then p.asetupfee + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 5 then p.bsetupfee + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 6 then p.monthly + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 7 then p.quarterly + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 8 then p.semiannually + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) when 9 then p.annually + (d.registrationperiod * ((d.idprotection * @idp) + (d.dnsmanagement * @dns) + (d.emailforwarding * @fwd))) end where d.is_premium != 1 and dp.extension = right(d.domain, length(d.domain) - locate('.', d.domain) + 1) and p.type = 'domainrenew' and p.relid = dp.id and c.id = d.userid and p.currency = c.currency; 4. Save the file and the run it against your work database:
      mysql workdb < ~/domain_pricing_sync.sql 5. Repeat step 2 and see what your total looks like after the update.
      Once you're comfortable the SQL works for you,  you can run it against your production database manually after you update domain pricing, or even schedule it via cron if you want to automatically keep pricing in sync. There probably isn't a good reason for setting it up to run via cron, unless like me you don't like the way WHMCS allows a user to register or manually renew a domain for X number of years, and then assumes the next renewal should be for that same number of years. I personally run this SQL daily via cron, with this line added to the very top of the SQL:
      update tbldomains set registrationperiod = 1; This way if a client has registered or manually renewed for longer than a year, this will reset the domain to a 1 year registration/renewal with the current pricing for one year. It can certainly be argued that it's a bit of an overkill to run it daily just to keep a few clients' domains who occasionally renew for longer periods reset to 1 year, but I do it anyway. For me it takes a little under a minute to run this against 5,135 domain names.
      The SQL is written to handle those who use multiple currencies (I do not), and does NOT adjust the pricing for any premium domain names that are properly set (tbldomains.is_premium = 1). It does update ALL domains regardless of status. An additional where clause to only update domains with certain statuses (i.e. where status = 'Active' or where status not in ('Expired', 'Cancelled', 'Fraud', 'Transferred Away')) can easily be added to limit the amount of records updated if you wish. This does not update any open invoices, so it's conceivable a client with an open renewal invoice will still pay an outdated price and have the domain renewed.
      WHMCS doesn't store the domain extension separately in the tbldomains table, so it has to be calculated on the fly, hence "right(d.domain, length(d.domain) - locate('.', d.domain) + 1)". The assumption is that everything including and to the right of the first instance of a period in the domain name represents the extension. I can't think of a case where this would present a problem, but it's possible and something to consider before deciding to use this.
      Someone who is more motivated than I could take this concept and build an addon module with more flexibility, such as nice UI providing the ability to only update selected TLDs with selected Status values or some such. Feel free to do so if you are so inclined.
      Use at your own risk and test thoroughly before running against your production db!
    • By ModulesGarden
      1. Easter Hunt Winners Announced!

      Are you excited about the grand finale of our Easter Discount Hunt just as much as we are?

      With the holiday break over, we are thrilled to invite you to visit our Blog where the 6 lucky winners of our festive competition have been announced - check the results now and see if you snatched up an exclusive 25% discount applicable to all WHMCS modules offered at our Marketplace!



      2. cPanel Extended For WHMCS 3.12.0

      Our absolutely bestselling piece of software dedicated to all aspiring web hosting providers has just received another package of new features that may change just about everything. Ladies and gentlemen, let us show you around the spectacular cPanel Extended For WHMCS 3.12.0!

      The most important addition guaranteed to steal your attention lies in DNS Zone Editor that unlocks so much new power to your clients as they will not have to login to cPanel at all in order to manage their DNS zones and records of cPanel domains.

      Do not hesitate to consult the changelog for the rest of beneficial changes!



      3. cPanel Extended For WHMCS is not the only module updated since last week. Ready to explore the other ones too?
      Plesk Key Administrator For WHMCS - v1.3.9 R1Soft Backups For WHMCS - v1.1.8 Social Media Login For WHMCS - v1.3.7

      Need Custom Software Development For Your Business?
       
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
    • By ModulesGarden
      1. Easter Discount Hunt - 25% OFF!

      In this season of renewal, new joys and fresh beginnings, we are sending best wishes of health, contentment and prosperity to all our clients and their families. May this Easter aslo bring growth and success to your business projects, relationships and ventures!

      To express our appreciation for your ongoing interest and cooperation, we warmly invite you to take part in our special Easter Egg Searching! Jump at the opportunity to add more cheer to this already festive aura, and indulge yourself in the pleasure of an egg-citing 25% discount!

      Test your eagle eye in the ModulesGarden Easter Hunt!



      2. Proxmox modules for WHMCS v3.1.0

      We put immense amount of development effort into each of our product. And those that our customers rely on most often - in particular. Result? A pivotal update of both Proxmox Cloud VPS For WHMCS and Proxmox VPS For WHMCS has just been officially made available to public to satisfy your eager anticipation with an impeccable custom Cloud-init support!

      While tracing the fresh potential unlocked by this collective 3.1.0 release, be sure to give special consideration to the force assignment of IP addresses that can be now executed via Cloud-init directly to the "IP Config" utility of Proxmox Virtual Environment. The new version has far more to offer so remember to take a careful look at the complete changelog.

      Learn more about the 3.1.0 edition of Proxmox Cloud VPS For WHMCS and Proxmox VPS For WHMCS!



      3. Here are some other of our most recent updates:
      Domain Allocator For WHMCS - v1.0.9 Emoji Picker For WHMCS - v1.1.5 NIC IT Registrar For WHMCS - v1.3.5

      Need Custom Software Development For Your Business?
       
      Get Your Free Quote Now! Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
    • By ModulesGarden
      Happy Easter to the entire WHMCS community!

      May the soul of the season bloom in your heart and bring along nothing but positive energy. Have a great time and a safe holiday with your beloved ones!
       
      We have also talked the Easter Bunny round to prepare a one-of-the-kind Grand Easter Chase for those who feel like adding some joy, and giving a marvellous 25% discount a hug!

      Enter our egg-stra Easter Hunt and claim your reward!
    • By SD-Reg
      hello all,
      We have successfully setup WHMCS and have a few hosting accounts running well, and are now testing out domain management. We are currently configured to use eNom as the registrar, sync appears to be working, and even the pricing sync is OK. We have initiated our first domain transfer away from GoDaddy into our own WHMCS environment.
      GoDaddy side is showing "transfer pending". It's now been past the waiting period and date they gave in email communication for able to reject the transfer, so we are anticipating the transfer to now go through. In an effort to research and follow it along to see where in the process it is, our WHMCS (both as an admin and also as the user who is transferring the domain) is showing "transferred away", and eNom does not list the domain. Are there any other troubleshooting steps to check?
      I guess we were expecting eNom to possibly have a "pending incoming" or something to show what is currently in process. Then the other confusing part is that WHMCS is showing transferred away - that makes sense from the GoDaddy side (even though it's not showing completed), but as far as our WHMCS and eNom is concerned, it should be incoming, and we don't appear to have a way to investigate further.
      thanks in advance!
  • 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