MainWP Community

Disable New Referral Email for Affiliates with Store Credit Disabled in AffiliateWP

Disable new referral email for affiliates with store credit disabled on child sites running AffiliateWP.

Snippet Type

Execute on Child Sites

Snippet

/*-- 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 );
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.