Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    Currently content will not be hidden in search results, archive pages or custom lists, but it is on the roadmap.

    However, as soon as the user clicks on the link to the restricted content, he will not be authorized.

    Let me know if this answers your question.

    Hi Joachim,
    I’m testing your plugin and it works fine. I like the way you coded it.
    I also need to hide products on archive page.
    How far is this feature in your roadmap?
    Thanks.
    franck.

    Plugin Author Joachim Jensen

    (@intoxstudio)

    I have not had time to work more on this feature, but the following snippet might help you.

    It will hide content from archive pages, blog pages, widgets and custom lists.
    However, it only works if you restrict content by specific posts:

    add_action( 'pre_get_posts', function($query) {
    	if (!is_admin() && !$query->is_singular() && (!isset($query->query["post_type"]) || $query->query["post_type"] != RUA_App::TYPE_RESTRICT)) {
    		global $wpdb;
    		$other_levels = array_diff(
    			array_keys(RUA_App::instance()->get_levels()),
    			RUA_App::instance()->level_manager->get_user_levels()
    		);
    		$result = $wpdb->get_col("SELECT m.meta_value FROM $wpdb->postmeta m INNER JOIN $wpdb->posts p ON m.post_id = p.ID WHERE m.meta_key = '_ca_post_type' AND p.post_parent IN ('".implode("','", $other_levels)."')");
    		if($result) {
    			$query->set('post__not_in', $result);
    		}
    	}
    	return $query;
    } );

    Let me know if it works for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How To Hide Product in wooCommerce ?’ is closed to new replies.