Guest User

Untitled

a guest
Jul 16th, 2013
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action( 'init', 'init_no_zero_notifications' );
  2.  
  3. function init_no_zero_notifications() {
  4.     add_action( 'affiliates_referral', 'no_zero_notifications', 9 );
  5.     add_action( 'affiliates_updated_referral', 'no_zero_notifications', 9 );
  6. }
  7.  
  8. function no_zero_notifications( $referral_id ) {
  9.     global $wpdb;
  10.     $referrals_table = _affiliates_get_tablename( 'referrals' );
  11.     $amount = $wpdb->get_var( $wpdb->prepare( "SELECT amount FROM $referrals_table WHERE referral_id = %d", $referral_id ) );
  12.     if ( floatval( $amount ) <= 0 ) {
  13.         remove_action( 'affiliates_referral', array( 'Affiliates_Notifications', 'affiliates_referral' ) );
  14.         remove_action( 'affiliates_updated_referral', array( 'Affiliates_Notifications', 'affiliates_updated_referral' ) );
  15.     }
  16. }
RAW Paste Data