3

I am creating a members only section and I am wondering if I can use the member_group variable, on its own, to check if a user is logged in or not. My assumption is that using both the logged_in variable and member_group variables at once creates a more resource heavy advanced conditional.

Basic example here:

{if logged_in AND member_group == "5"}
    logged in content (member group 5 view) 
{if:else}
    logged out content (public view)
{/if}

However, if users are not a part of any member group I create, or they are not a super admin, then they default to the Guest member group 3. This represents anyone not logged in. At least that is how I understand it.

But if EE identifies a user as belonging to any member group other than Guest, doesn't that mean they are logged in? If this is the case, then I should be able to use simple member group conditionals to check logged in status.

Does this sound right or am I missing something?

3

Yes, you can use group_id (or preferably logged_in_group_id) on its own - no need to include logged_in as well in the conditional.

| improve this answer | |
  • Ah, I didn't realize there was a logged_in_group_id variable. Good to know. Thank you. – sam.digital Dec 20 '13 at 16:39
  • be aware though that logged_in_... variables are parsed late. Any tags between the conditionals are all parsed and only the resulting output will be discarded or shown based on the conditional. – GDmac Dec 22 '13 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.