Random affiliate

Hi,

Could you suggest solution (maybe hook) to assign affiliate based on my algorithm?

ex: if there is no referal link, I would like to select random affiliate /or based on my method/ and persist it.

How could I make it?

Denis


Comments

One response to “Random affiliate”

  1. Hi Dennis,

    You should check the option to store Direct referrals, when there is no affiliate attributable.
    Then you should use the filter affiliates_service_affiliate_id if the affiliate_id=1( Direct affiliate’s id), apply your method and return that affiliate_id.


    add_filter( 'affiliates_service_affiliate_id', 'gt_affiliate_id', 10 , 2 );
    function gt_affiliate_id ( $affiliate_id, $service ) {
    if ( $affiliate_id == 1 ) {
    //...calculate the new affiliate_id
    //...set it as the affiliate_id
    $affiliate_id = 7; //for example affiliate with id 7
    }

    return $affiliate_id;
    }

    Kind regards,
    George

Share