Is there a way to check if someone is logged in, and their membership level, within a post? I want to create a snippet/card that would only show if someone is not logged in. Extra points if I can customize it to show different messages to subscribers versus members.
Related: Would it be possible to build the code using handlebars and put it in the code injection section of the admin?
Not within a post directly because post content is static.
What you could potentially do is add a html card with an insertion point such as <div class="member-cta"></div>. Then in your theme’s post template add some JS that gets inserted into that div. Eg:
<script>
{{#if @member.paid}}
document.querySelector('.member-cta').innerHTML = '<p>Thanks for being a paid member!</p>';
{{else if @member}}
document.querySelector('.member-cta').innerHTML = '<p>Thanks for being a member! Why not become a <a href="#/portal/signup">paid member for full access</a></p>';
{{else}}
document.querySelector('.member-cta').innerHTML = '<p><a href="#/portal/signup">Sign up<a> or <a href="#/portal/signin">sign in</a></p>';
{{/if}}
</script>
Follow-up: Would it be better practice to put the script in its own file, then call it from within the post.hbs file? I think I know how to do that, if I dig around in the docs.