function memberful_wp_shortcode($atts, $content) { $show_content = FALSE; $does_not_have_download = $does_not_have_subscription = NULL; $atts = memberful_wp_normalize_shortcode_args($atts); $shortcode_is_checking_if_the_user_has_stuff = empty($atts['does_not_have_subscription_to']) && empty($atts['does_not_have_download']); if ($shortcode_is_checking_if_the_user_has_stuff && current_user_can('publish_posts')) { return do_shortcode($content); } if (!empty($atts['has_subscription_to'])) { $show_content = is_subscribed_to_memberful_plan($atts['has_subscription_to']); } if (!empty($atts['has_download'])) { $has_download = has_memberful_download($atts['has_download']); $show_content = $show_content || $has_download; } if (!empty($atts['does_not_have_subscription_to'])) { $does_not_have_subscription = !is_subscribed_to_memberful_plan($atts['does_not_have_subscription_to']); } if (!empty($atts['does_not_have_download'])) { $does_not_have_download = !has_memberful_download($atts['does_not_have_download']); } if ($does_not_have_download !== NULL || $does_not_have_subscription !== NULL) { $requirements = array($does_not_have_subscription, $does_not_have_download); if (in_array(FALSE, $requirements, TRUE)) { // User may have access to either the mentioned download or the subscription $show_content = FALSE; } else { // All specified requirements have been satisfied, so show content $show_content = TRUE; } } return $show_content ? do_shortcode($content) : ''; }
/** * @param string $success_message - '', if present, will return an clickable link * @param string $error_message - "You don’t have access to this RSS feed." * @param bool $return * @return string */ function memberful_private_rss_feed_link($success_message = '', $error_message = "You don’t have access to this RSS feed.", $return = false) { $error_message = apply_filters('memberful_private_rss_feed_error_message', $error_message); if (!is_user_logged_in()) { return memberful_private_rss_feed_link_response_helper($error_message, $return); } $requiredPlan = memberful_private_user_feed_settings_get_required_plan(); // We want to allow the private user feed only if the admin has configured it. if ($requiredPlan == false) { return memberful_private_rss_feed_link_response_helper($error_message, $return); } $current_user_id = get_current_user_id(); if (!is_subscribed_to_memberful_plan($requiredPlan, $current_user_id)) { return memberful_private_rss_feed_link_response_helper($error_message, $return); } $feedToken = get_user_meta($current_user_id, 'memberful_private_user_feed_token', true); if ($feedToken == false || $feedToken == '') { $feedToken = substr(md5(uniqid(rand(1, 10000))), 2, 30); update_user_meta($current_user_id, 'memberful_private_user_feed_token', $feedToken); } $link = get_home_url() . '/' . memberful_private_user_feed_get_url_identifier($feedToken); if ($success_message != '') { $link = '<a href="' . $link . '">' . do_shortcode($success_message) . '</a>'; } return memberful_private_rss_feed_link_response_helper($link, $return); }
/** * @deprecated 1.6.0 */ function has_memberful_subscription($slug, $user_id = NULL) { return is_subscribed_to_memberful_plan($slug, $user_id); }