Action affiliates_added_affiliate_relation won´t run

Hi,

I have a Affiliates Enterprise license and i´m trying use the action affiliates_added_affiliate_relation, but it simply won´t run when i establish a relation between two affiliates.

i dont even get a error message on screen or in the error log

I´m able to run other actions affiliates_added_affiliate and affiliates_updated_affiliate, but that specific one wont run

this is a basic sample that i did for testing purpose

function inf_affiliate_relation($from_affiliate_id,$to_affiliate_id){

file_put_contents(“relation.txt”, “From:”.$from_affiliate_id.” To:”.$to_affiliate_id );

echo “From:”.$from_affiliate_id.” To:”.$to_affiliate_id;

}
add_action(‘affiliates_added_affiliate_relation’, ‘inf_affiliate_relation’);

can someone help me?

thanks

8 Responses to Action affiliates_added_affiliate_relation won´t run

  1. George July 14, 2017 at 2:26 pm #

    Perfect!! 🙂
    You are welcome!

  2. Bruno July 14, 2017 at 7:03 am #

    it worked!

    thank you very much!

  3. George July 13, 2017 at 7:50 am #

    You probably haven’t enabled tiers under Affiliates > Tiers.
    This hook is invoked after a relation between two affiliates has been established. You should enable tiers and try again.

    Cheers,
    George

  4. Bruno July 12, 2017 at 8:47 pm #

    Ps: i was doing the testing by registering as with new accounts and also adding by the Affiliates > Referrals part

    in both cases it they did the connection of Affiliate and referring affiliate, but didn´t run the action affiliates_added_affiliate_relation

    Regards

  5. Bruno July 12, 2017 at 8:43 pm #

    Ive followed the instructions but i cant see an referrer section where i can select a referring affiliate

    in the “Edit an affiliate” there only the user fields name, email, etc

    bellow that, there is a Affiliate Attributes part, but there is no option to select a referring affiliate

    do i need to set something elsewhere for this to be displayed?

    Regards

  6. George July 12, 2017 at 9:09 am #

    Hi Bruno,

    There is a quick test you can perform for this hook.
    Go to Affiliates > Manage Affiliates. Then edit an affiliate, scroll down to Referrer section, select a referring affiliate and then click Assign button.
    With my snippet, you should see some data stored under wp-admin/relation.txt. Also note that depending on your theme, the echoed message might only show up if you view source html of your home page.

    Please check the above and let me know.

    Cheers,
    George

  7. Bruno July 11, 2017 at 9:29 pm #

    Hi George,

    i tried that now, but didn´t work

    debug is enabled but also doesn´t show any messages

    Regards

  8. George July 11, 2017 at 2:48 pm #

    Hi Bruno,

    You are missing two arguments in your implementation, $relation_type and $date. If you have enabled debugging, you should see the Notices logged there.
    The proper hook should look like this:

    function inf_affiliate_relation( $from_affiliate_id, $to_affiliate_id, $relation_type, $date ) {

    file_put_contents("relation.txt", "From:".$from_affiliate_id." To:".$to_affiliate_id );

    echo "From:".$from_affiliate_id." To:".$to_affiliate_id;
    }
    add_action('affiliates_added_affiliate_relation', 'inf_affiliate_relation', 10, 4 );

    Cheers,
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share