Created
July 31, 2018 12:14
-
-
Save wpmudev-sls/2721432af9fe1e7b4a4e4305fd255c84 to your computer and use it in GitHub Desktop.
Affiliate - limit affiliate commission period with in m2p addons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Affiliate - limit affiliate commission period with in m2p addons | |
* Plugin URI: https://premium.wpmudev.org/ | |
* Description: This will help to limit the affiliate commission with a specific time like 1 year from the initial subscription | |
* Author: Ariful Islam @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/profile/itsarifulislam | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_filter( 'affiliate_process_payment', function( $status, $user_id_referrer, $reward, $user_id, $meta ) { | |
if ( ! class_exists('MS_Factory') ) return $status; | |
$subscription = MS_Factory::load( 'MS_Model_Relationship', $meta['subscription_id'] ); | |
$start_date = $subscription->start_date; | |
$end_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($start_date)) . " + 1 year")); | |
$end_date = DateTime::createFromFormat('Y-m-d', $end_date); | |
$today = new DateTime(); | |
return $today < $end_date; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment