Example #1
0
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) : '';
}
Example #2
0
/**
 * @deprecated 1.6.0
 */
function has_memberful_product($slug, $user_id = NULL)
{
    return has_memberful_download($slug, $user_id);
}