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


Comments

8 responses to “Action affiliates_added_affiliate_relation won´t run”

  1. Perfect!! 🙂
    You are welcome!

  2. it worked!

    thank you very much!

  3. 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. 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. 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. 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. Hi George,

    i tried that now, but didn´t work

    debug is enabled but also doesn´t show any messages

    Regards

  8. 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

Share