Question about affiliate and membership 2 pro.

If we use define( 'AFFILIATE_PAYONCE', 'no' ); affiliates will be paid for every single payment made by the referred user. if the subscription is for a year, but then needs to be renewed, for example, does the affiliate plugin 'pay' for the 1 year, or forever i.e. for as long as the person is a member? If forever, is there a way to set it up that it is only for 1 year?

  • Dr48

    Hi James,

    Any updates here? Query is to ensure if an affiliate signs a person up for a subscription membership that the affiliate then is 'paid' each time the subscriber (referred) makes a payment -- up to the first year before 'removing' affiliate association i.e. so the initial affiliate/referred relationship is then dropped so the initial affiliate (user) gets paid for the entire year (but not 5 years, for example) -- would really appreciate any further insights with this and/or if this is still being looked into.

    Thank you kindly :slight_smile:

  • Ari

    Hey Dr48

    This is possible and I made the solution for you, but I added a WordPress Filter Hook in our plugin, and forwarded this to our plugins developer, so they have a review for future update.

    Using this hook, I made the solution for you, what I made is just checking the subscription date if that pass 1 year, block the payment.

    Please follow the steps below:

    1: Replace this file plugins/affiliate/affiliateincludes/addons/membership2.php with the attached one, make sure you unzipped it first.
    2: Now in the wp-content folder create mu-plugins folder if that already not exist.
    3: Download the gist file of this solution from https://gist.github.com/wpmudev-sls/2721432af9fe1e7b4a4e4305fd255c84
    4: Unzip it, copy the file and upload it to the mu-plugins folder.

    === What is mu-plugins? ===

    mu-plugins also called "must use plugins" is auto-activated plugin, that's mean by adding that file inside the "mu-plugins" the code is automatically start functioning without any activation from dashboard.
    If you need to more about mu-plugins, here's the link: https://codex.wordpress.org/Must_Use_Plugins
    In future if you need to deactivate it, just remove this file.

    === What I changed in the plugin's file ===

    I usually added this two lines:

    $affiliate_process_payment = apply_filters( 'affiliate_process_payment', true, $user_id_referrer, $reward, $user_id, $meta );
    
    if ( ! $affiliate_process_payment ) return;

    just before:

    do_action(
    	'affiliate_purchase',
    	$user_id_referrer,
    	$reward,
    	self::AREA_KEY,
    	$user_id,
    	__( 'Membership2', 'affiliate' ),
    	$meta
    );

    Let me know if you need any help regarding this.

    Best Regards,
    Ari

  • Dr48

    Hi Ari,

    That's seems great for the work-around -- thank you very much :slight_smile:

    My query is does this fix 1. affiliate gets paid 'each payment' for the whole year, and then 2. after the 1 year is over, the affiliate relationship to that user is null (cancelled) so then 3. affiliate is rewarded for the 1st year only?

    May you please let me know if this is the case?

    Also, if you wouldn't mind, can you provide further steps on how to place the above file and code -- I'm a bit confused here.

    Thank you kindly Ari, and for the brilliant work-around :slight_smile:

  • Ari

    Hey Dr48

    In my above solution I covered number 1 & 3, not the number 2, and without number 2 I could achieve number 3.

    Is that OK for you? or I also should achieve the number 2, I'm not sure if that could be possible without any issue, I mean if I do this it could cause another issue.

    Let me know what do you think?

    === In my above reply I already suggested you how to apply this solution ===
    === I'm repeating here again ===

    Please follow the steps below:

    1: Replace this file plugins/affiliate/affiliateincludes/addons/membership2.php with the attached one, make sure you unzipped it first.
    2: Now in the wp-content folder create mu-plugins folder if that already not exist.
    3: Download the gist file of this solution from https://gist.github.com/wpmudev-sls/2721432af9fe1e7b4a4e4305fd255c84
    4: Unzip it, copy the file and upload it to the mu-plugins folder.

    =====

    Best Regards,
    Ari

  • Dr48

    Thank you very much Ari -- I was in need of a little help to make this happen but has now been done -- is there anything more that i need to do and/or is there a way that i can check that these rules work? i.e. affiliate relationship for one year only? Also, after that year what is the default behaviour with these rules applied?

    Thank you very much Ari for your work-around and help :slight_smile:

  • Ari

    Hey Dr48

    Hope you are well,

    === Is there anything more that I need to do ===
    No, you don't need to do anything, if you already did my above things, I repet that:
    1: Replace the plugin file: plugins/affiliate/affiliateincludes/addons/membership2.php with my provided one.
    2: Download and put limit-affiliate-commission.php gist file in the wp-content/mu-plugins folder.

    since mu-plugins are auto activated plugin, that's why you don't need to do anything to activate it.

    === Is there a way that I can check that these rules work ===
    Yeah, there's a way, but critical, if you want to test it, follow the below steps:

    --- Setup ---
    1: Install both plugin's
    2: Make sure you replaced the affiliate plugin's file with my provided one.
    3: Also make sure you added my mu-plugin
    4: In the wp-config add define( 'AFFILIATE_PAYONCE', 'no' );

    --- Config ---
    5: Enable Affiliate from Users -> Affiliate Referrals page
    6: In the membership plugin, create a paid membership, and setup a gateway in sandbox mode, also setup the affiliate commission for that membership.

    --- Testing #1 ---
    7: Open a different browser
    8: Copy the affiliate code and past
    9: Signup to a paid membership
    10: Now check in the first browser if you get the affiliate commission
    11: Renew the memberhsip and check if you get the another commission. ( so the affiliate commission is working )

    --- Testing #2 ---
    We will check here if our code is working.

    12: Edit the mu-plugin: on line 21: change the $subscription->start_date to 1 year older date like 2017-07-12 and assume this is the subscription date, then our plugin will set the expire date by adding 1 year to it, so in this case the expire date will be: 2018-07-12 which is expired compared with current date, in this case affiliate should not get commissioned!

    13: Again renew the membership, and check the commission, I hope this time affiliate user will not get any commission.

    14: Again change the 2017-07-12 to 2017-10-12, so our plugin will set expire date by adding 1 year then it will be 2018-10-12, which is not expired yet, so affiliate should get commissioned now.

    15: Again renew the membership, and check the commission, I hope this time affiliate user will get the commission.

    === Ffter 1 year what is the default behaviour with these rules applied ===

    What we understand if the $subscription->start_date is 1 year older compared with the current date, affiliate user will not get any commission for any payment in this subscription.

    But if that user subscribe to another membership, affiliate user will get the commission for 1 year for this new subscription.

    Best Regards,
    Ari

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.