/** * WooCommerce Membership compatibility * Show Builder contents only if user has access * * @return bool */ public function wc_memberships_themify_builder_display($display, $post_id) { if (wc_memberships_is_post_content_restricted()) { return false; } return $display; }
/** * Restrict (post) content based on content restriction rules * * @since 1.0.0 * @param string $content The content * @return string */ public function restrict_content($content) { // Check if content is restricted - and this function is not being recursively called // from `get_the_excerpt`, which internally applies `the_content` to the excerpt, which // then calls this function, ... until the stack is full and I want to go home and not // deal with this anymore... if (wc_memberships_is_post_content_restricted() && !doing_filter('get_the_excerpt')) { global $post; // Check if user has access to restricted content if (!current_user_can('wc_memberships_view_restricted_post_content', $post->ID)) { // User does not have access, filter the content $content = ''; if (!in_array($post->ID, $this->content_restriction_applied)) { if ('yes' == get_option('wc_memberships_show_excerpts')) { $content = get_the_excerpt(); } $content .= '<div class="woocommerce"><div class="woocommerce-info wc-memberships-restriction-message wc-memberships-message wc-memberships-content-restricted-message">' . wc_memberships()->frontend->get_content_restricted_message($post->ID) . '</div></div>'; } } else { if (!current_user_can('wc_memberships_view_delayed_post_content', $post->ID)) { // User does not have access, filter the content $content = ''; if (!in_array($post->ID, $this->content_restriction_applied)) { if ('yes' == get_option('wc_memberships_show_excerpts')) { $content = get_the_excerpt(); } $content .= '<div class="woocommerce"><div class="woocommerce-info wc-memberships-restriction-message wc-memberships-content-delayed-message">' . wc_memberships()->frontend->get_content_delayed_message(get_current_user_id(), $post->ID) . '</div></div>'; } } } // Indicates that the content for this post has already been filtered $this->content_restriction_applied[] = $post->ID; } return $content; }