-
-
Save Spellhammer/a5be07c478eabb11aa7fb604d601b2a7 to your computer and use it in GitHub Desktop.
EDD Conditions
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
if( function_exists('oxygen_vsb_register_condition') ) { | |
oxygen_vsb_register_condition('User...', array('options'=>array(), 'custom'=>true), array('has purchased', 'has not purchased'), 'ex_edd_has_user_purchased_callback', 'EDD'); | |
function ex_edd_has_user_purchased_callback($value, $operator) { | |
$current_user = get_current_user_id(); | |
$value = intval($value); | |
if( $operator == 'has purchased' ) { | |
if( edd_has_user_purchased($current_user, $value) ) { | |
return true; | |
} else { | |
return false; | |
} | |
} else if( $operator == 'has not purchased' ) { | |
if( !edd_has_user_purchased($current_user, $value) ) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
oxygen_vsb_register_condition('User is...', array('options'=>array(), 'custom'=>true), array('subscribed to', 'not subscribed to'), 'ex_edd_has_active_subscription_callback', 'EDD'); | |
function ex_edd_has_active_subscription_callback($value, $operator) { | |
$subscriber = new EDD_recurring_subscriber( get_current_user_id() ); | |
$value = intval($value); | |
if( $operator == 'subscribed to' ) { | |
if( $subscriber->get_subscriptions( $value, array( 'active' ) ) ) { | |
return true; | |
} else { | |
return false; | |
} | |
} else if( $operator == 'not subscribed to' ) { | |
if( !$subscriber->get_subscriptions( $value, array( 'active' ) ) ) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment