Last active
April 26, 2023 12:47
-
-
Save contemplate/4fb5528d642a8e63846ebda6534f66b7 to your computer and use it in GitHub Desktop.
AffiliateWP: Disable New Referral Email for Affiliates with Store Credit Disabled
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
/*-- Disable New Referral Email for PAID Affiliates -----------*/ | |
function disable_new_refferal_email( $return, $referral ) { | |
// Check to see if AffiliateWP is active. | |
if ( ! function_exists( 'affiliate_wp' ) ) { | |
return; | |
} | |
$affiliate_id = $referral->affiliate_id; | |
$store_credit_disabled = affwp_get_affiliate_meta( $affiliate_id, 'store_credit_disabled', true ); | |
// If Store Credit Disable cancel email | |
if( $store_credit_disabled ) { | |
$return = false; | |
} | |
return $return; | |
} | |
add_filter( 'affwp_notify_on_new_referral', 'disable_new_refferal_email', 10, 2 ); |
Assumes this addon in enabled:
https://github.com/AffiliateWP/affiliatewp-code-snippet-library/blob/master/add-ons/store-credit/affwp-store-credit-disable-per-affiliate-when-globally-enabled.php
looks like the above plugin has been removed so I added it here:
https://gist.github.com/contemplate/1b09fba662969638866bcaa94e62fd3c
This was very useful. I am not good with PHP but can you help me create a similar filter to not send new referral email if referral amount is less than 10. I know its a long shot, any help will be awesome.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used in cases where Store Credit plugin is setup and enabled for all but disabled for some.