Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Affiliate - limit affiliate commission period with in m2p addons
<?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
You can’t perform that action at this time.