Show a field to logged-in user in Drupal 8 views I have some fields in my views called products but only logged in users will be able to see the product price field.

I am using twig. 

I tried using. 

&lt;div class="menu-items"&gt;
  &lt;div class="shopcat-image"&gt;{{ uc_product_image }}&lt;/div&gt;
  &lt;h3 class="font-bold font-black"&gt;{{ title }} &lt;/h3&gt;
  {% if logged_in %} &lt;span class="price"&gt;{{ price }}&lt;/span&gt; {% endif %}
  &lt;div class="item-sku text-center"&gt;
  &lt;strong&gt;Item # : &lt;/strong&gt; {{ model }}&lt;/div&gt;
&lt;/div&gt;


In custom text

but still not working.
If you want to hide the price field globally to anonymous users, consider using something like field permissions.

https://www.drupal.org/project/field_permissions

This could potentially hide the price in any context it is displayed.

If you need to use twig, other solutions include overriding the templates for the view(s) and/or the field itself. 

I would recommend addressing this kind of override from a code side, as it could potentially reveal sensitive information based on the front-end.