EDD Conditions
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