Score:0

If content not published, hide also for admin

kn flag

I have a entity browser which list my produts. The products are shown only if they are published.

enter image description here

But for some reason, if the product was added before the filtered "publish" was set, the product is still displayed but only for the admin.

How can I prevent the admin to see it ?

EDIT :

For now, I've added a manual check in twig, but i think there's a cleaner way to do it

{% for produit in produits %}
   {% if produit['#commerce_product'].published %}
      {{ produit }}
   {% endif %}
{% endfor %}
Score:1
cn flag

User accounts with permission to view unpublished content can view content.

Usually, the administrator role has the Administer content permission, so admins will see unpublished nodes.

To prevent this, go to /admin/people/permissions, scroll down to the Node category, and remove the Administer content permission as well as Bypass access control and any other permissions that may allow access to unpublished nodes (contrib modules can add permissions, so I can't list them all here).

If you only have one administrator role, you may want to create a separate role for this purpose.

kn flag
Thanks a lot ! That's it
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.