How to check if user is under a given Plan and/or have an Active Subscription
As a network admin you may need to create custom functions that will perform basic actions or make a service/feature available to a selected group of subscribers or end-users, based on the status of their subscription and "plan" they are subscribed under.
These WP Ultimo native functions will help you with that.
To check if the user is a member of a given plan, you can use the function:
wu_has_plan($user_id, $plan_id)
To check if the subscription is active, you can use the function:
wu_is_active_subscriber($user_id)
Below is an example snippet that check whether the current user is under a specific plan (Plan ID 50) and if the user subscription is active.
$user_id = get_current_user_id();
$plan_id = 50;
if (wu_has_plan($user_id, $plan_id) && wu_is_active_subscriber($user_id)) {
// USER IS MEMBER OF PLAN AND HIS SUBSCRIPTION IS ACTIVE, DO STUFF
} else {
// USER IS NOT A MEMBER OF PLAN -- OR -- HIS SUBSCRIPTION IS NOT ACTIVE, DO OTHER STUFF
} // end if;
Note that wu_has_plan requires a "Plan ID" in order for it to function.