Esempio n. 1
0
/**
 * Check that the specified user is subscribed to at least one of the specified plans
 *
 * @param int   $user_id The id of the wordpress user
 * @param array $subscriptions Ids of the subscriptions to restrict access to
 * @return boolean
 */
function memberful_wp_user_has_subscription_to_plans($user_id, array $required_plans)
{
    $plans_user_is_subscribed_to = memberful_wp_user_plans_subscribed_to($user_id);
    foreach ($required_plans as $plan) {
        if (isset($plans_user_is_subscribed_to[$plan])) {
            $subscription = $plans_user_is_subscribed_to[$plan];
            if (empty($subscription['expires_at']) || $subscription['expires_at'] > time()) {
                return TRUE;
            }
        }
    }
    return FALSE;
}
Esempio n. 2
0
/**
 * @deprecated 1.6.0
 */
function memberful_wp_user_subscriptions($user_id)
{
    return memberful_wp_user_plans_subscribed_to($user_id);
}
Esempio n. 3
0
 public function update_user_role(WP_User $user)
 {
     $new_role = $this->role_for_user(reset($user->roles), memberful_wp_user_plans_subscribed_to($user->ID));
     $user->set_role($new_role);
 }