PHP Functions

From HurryPress Documentation
Jump to: navigation, search

There are 2 simple PHP functions available to check subscription status in a custom WP plugin/theme.

/***
 * Return current user status in HurryPress
 * 0 - pending (also returned for not-logged-in-users)
 * 1 - active (have at least one active subscription)
 * 2 - expired (had a subscription and now all subscriptions are expired) */
hp_user_status();

// example
if (hp_user_status() == 1) {
    echo "You have an active subscription";
} else {
    echo "You have no active subscription";
}
/***
 * Return true if user has active subscription to any product in $product_ids list
 * Return false if user is not logged-in or have no required subscription
 * Use numeric product ids here
 */
function hp_user_check_access(array $product_ids);


// example 
if (hp_user_check_access(array(2,3,4)) {
    echo "User has access to product #2,#3 or #4";
} else {
    echo "User has no access to product #2,#3 and #4";
}