/**
 * Filter restricted content based on category restrictions
 *
 * @access      public
 * @since       2.0
 * @return      $content
 */
function rcp_filter_restricted_category_content($content)
{
    global $post, $rcp_options;
    $restrictions = array();
    foreach (rcp_get_restricted_taxonomies() as $taxonomy) {
        $restriction = rcp_is_post_taxonomy_restricted($post->ID, $taxonomy);
        // -1 means that the taxonomy terms are unrestricted
        if (-1 === $restriction) {
            continue;
        }
        // true or false. Whether or not the user has access to the restricted taxonomy terms
        $restrictions[] = $restriction;
    }
    if (empty($restrictions)) {
        return $content;
    }
    $restricted = apply_filters('rcp_restricted_taxonomy_match_all', false) ? false !== array_search(true, $restrictions) : false === array_search(false, $restrictions);
    if ($restricted) {
        $message = !empty($rcp_options['paid_message']) ? $rcp_options['paid_message'] : __('You need to have an active subscription to view this content.', 'rcp');
        return rcp_format_teaser($message);
    }
    return $content;
}
 /**
  * Loads the restricted content template if required.
  *
  * @access  public
  * @since   2.5
  */
 public function hide_template($template, $slug, $name)
 {
     $product_id = get_the_ID();
     if (!is_singular('product')) {
         return $template;
     }
     if ('content-single-product' !== $slug . '-' . $name) {
         return $template;
     }
     if (current_user_can('edit_post', $product_id)) {
         return $template;
     }
     $active_only = get_post_meta($product_id, '_rcp_woo_active_to_view', true);
     $levels = (array) get_post_meta($product_id, '_rcp_woo_subscription_levels_to_view', true);
     $access_level = get_post_meta($product_id, '_rcp_woo_access_level_to_view', true);
     $product_cat = rcp_is_post_taxonomy_restricted($product_id, 'product_cat');
     $product_tag = rcp_is_post_taxonomy_restricted($product_id, 'product_tag');
     /**
      * rcp_is_post_taxonomy_restricted() returns:
      * - true when restrictions are found for the current user
      * - false when restrictions are not found for the current user
      * - -1 when no terms are assigned, for which we don't care.
      * We're normalizing the value here. If the value is false,
      * the user has already passed the restriction checks.
      */
     $cat_restricted = true === $product_cat ? true : false;
     $tag_restricted = true === $product_tag ? true : false;
     // Return early if no restrictions
     if (!$active_only && empty($levels[0]) && !$access_level && !$cat_restricted && !$tag_restricted) {
         return $template;
     }
     $visible = true;
     // Active subscription setting
     if ($active_only && !rcp_is_active()) {
         $visible = false;
     }
     // Subscription level setting
     if (!in_array(rcp_get_subscription_id(), $levels)) {
         $visible = false;
     }
     // User level setting
     if ($access_level && rcp_user_has_access(get_current_user_id(), $access_level)) {
         $visible = false;
     }
     if ($visible) {
         return $template;
     }
     return rcp_get_template_part('woocommerce', 'single-no-access', false);
 }