We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Cannot use member id as dynamic conditional variable

How Do I?

sheferd's avatar
sheferd
31 posts
10 years ago
sheferd's avatar sheferd

I’m building a system where entries should have specific member access.

I have a parent template that checks member group which then embeds a template specific to this and then lists entries which should only display if the current member ID matches the specified entry ID. Problem is using the ‘member_id’ or ‘logged_in_member_id’ won’t work.

I’ve tried a number of ways to do this but none work.

Firstly I’ve tried directly:

{if '{pref_member_access}' == '{member_id}/{logged_in_member_id'}
do a thing
{/if}

Next I tried embedding the id:

{if '{pref_member_access}' == '{embed:mem_id}'}
do a thing
{/if}

with parent:

{embed="_page/.pref_list" mem_id="{member_id}/{logged_in_member_id}"}

and also I’ve tried with stash:

{exp:stash:set name="mem_id"}{member_id}/{logged_in_member_id}{/exp:stash:set}

These will all work and give me the correct output inside the embeded template but NOT if I try to use the output inside the conditional.

Just to clarify I am not using ‘{member_id}/{logged_in_member_id}’ as I have put it in the code above, I have used either/or

If I specify a member ID the conditional will work:

{embed="_page/.pref_list" mem_id="8"}
or
{exp:stash:set name="mem_id"}8{/exp:stash:set}
for example

even if I try to ‘stash’ the member ID at my master template it won’t work as a dynamic value either.

(you can probably ignore the stash code if you are unfamiliar with it, this isn’t really regarding that, I’m just trying to use the current logged in members ID as a dynamic value)

Any ideas?

Thanks

       
sheferd's avatar
sheferd
31 posts
10 years ago
sheferd's avatar sheferd

Just to update my issue turned out to be, I had ‘member_data’ disabled in my channel entries tag

disable="member_data|pagination|trackbacks"

after removing that I was able to use {logged_in_member_id}.

…now I have another issue but I’ll post that if it comes to it.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.