Last active
October 15, 2021 23:38
-
-
Save freakdesign/95b6d4f02bd7b4f4a1ba to your computer and use it in GitHub Desktop.
Detect if an admin is logged into Shopify using liquid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Simple method for detecting an Admin in Shopify using liquid. | |
Quick code by jason at freakdesign.com.au | |
Related Blog post: http://freakdesign.com.au/blogs/news/34154561 | |
--> | |
{% capture CFH %}{{ content_for_header }}{% endcapture %}{{ CFH }} | |
{% if CFH contains 'admin_bar_iframe' %} | |
{% assign isAdmin = true %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shopify uses:
adminBarInjector
when you are viewing the live themepreviewBarInjector
when you are previewing a non-live themethis whole snippet will trigger a Shopify theme-check linter
ContentForHeaderModification
error but I'm choosing to ignore it