hostwes Posted December 29, 2008 Share Posted December 29, 2008 Is there a way to automatically activate a client when they sign up as an affiliate? Please let me know if you have a solution. Thanks. 0 Quote Link to comment Share on other sites More sharing options...
Troy Posted December 29, 2008 Share Posted December 29, 2008 This is untested, off the top of my head, but should get you going in the right direction. If you run this query on your WHMCS database at whatever interval you choose, it should insert affiliate records for all clients who aren't yet affiliates, so if you run it say every day, every hour, whatever it'll basically take any new, active clients who aren't yet affiliates and make them affiliates: INSERT INTO tblaffiliates (date, clientid, visitors, paytype, payamount, balance, withdrawn) SELECT DATE(NOW()), c.id, 0, "", 0, 0 FROM tblclients c where c.status = 'Active' and c.id not in (select clientid from tblaffiliates) The query assumes you have set up default affiliate payout values that you want to use for everyone, hence paytype being blank and payamount being zero. I'm still on 3.7.2, so double check the tblaffiliates structure for changes if you've upgraded to 3.8.1. You can put the query into a file, say /home/[user]/sql/affiliates.sql, and then run it from the root crontab with this command: mysql -D [dbname] < /home/[user]/sql/affiliates.sql (Change [dbname] to the name of your database, and [user] to the name of your whmcs site user, assuming you're running on cPanel as we are.) If you prefer instead to run the cron from the whmcs site user's crontab, you'll have to add username and password parameters to the mysql command. You'll want to incorporate your affiliate TOS into your main TOS if you do this automatically for all clients. 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.