/** * Hide private pages and pages that require a subscription feature level the subscriber does not have */ public function hidePrivatePages($excludes) { global $wpdb; $hidePrivate = true; $mySubItemNums = array(); $activeAccount = false; $featureLevel = false; if (Cart66Common::isLoggedIn()) { $hidePrivate = false; $account = new Cart66Account(Cart66Session::get('Cart66AccountId')); if ($account->isActive()) { $activeAccount = true; $featureLevel = $account->getFeatureLevel(); } // Optionally add the logout link to the end of the navigation if (Cart66Setting::getValue('auto_logout_link')) { add_filter('wp_list_pages', array($this, 'appendLogoutLink')); } // Hide guest only pages $guestOnlyPageIds = Cart66AccessManager::getGuestOnlyPageIds(); $excludes = array_merge($excludes, $guestOnlyPageIds); } // Hide pages requiring a feature level that the subscriber does not have $hiddenPages = Cart66AccessManager::hideSubscriptionPages($featureLevel, $activeAccount); if (count($hiddenPages)) { $excludes = array_merge($excludes, $hiddenPages); } if ($hidePrivate) { // Build list of private page ids $privatePageIds = Cart66AccessManager::getPrivatePageIds(); $excludes = array_merge($excludes, $privatePageIds); } // Merge private page ids with other excluded pages if (is_array(get_option('exclude_pages'))) { $excludes = array_merge(get_option('exclude_pages'), $excludes); } sort($excludes); return $excludes; }
/** * This is the inverse of the showTo shortcode function above. */ public function hideFrom($attrs, $content = 'null') { $isAllowed = true; if (Cart66Common::isLoggedIn()) { $levels = Cart66Common::trimmedExplode(',', $attrs['level']); $account = new Cart66Account(); if (in_array('all_members', $levels)) { $isAllowed = false; } elseif ($account->load(Cart66Session::get('Cart66AccountId'))) { if ($account->isActive() && in_array($account->getFeatureLevel(), $levels)) { $isAllowed = false; } } } $content = $isAllowed ? $content : ''; return do_shortcode($content); }
public function getMembershipPrice() { // Return pricing (if applicable) for different membership levels // Otherwise, just return the default pricing (without options or fancy subscription stuff) $price = $this->price; if (Cart66Common::isLoggedIn()) { $levels = Cart66Common::trimmedExplode(',', $this->priceMembership); foreach ($levels as $level) { list($subscription, $p) = Cart66Common::trimmedExplode(':', $level); $membershipPriceList[$subscription] = $p; } $account = new Cart66Account(); if ($account->load(Cart66Session::get('Cart66AccountId'))) { $userFeatureLevel = $account->getFeatureLevel(); if ($account->isActive() && array_key_exists($userFeatureLevel, $membershipPriceList)) { $price = $membershipPriceList[$userFeatureLevel]; } } } return $price; }