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.