Jump to content

How TO: Activate Affiliate when Client Registers...


hostwes

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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