ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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.

...I also somehow have 2 accounts

share|improve this answer

Try using {logged_in_member_id} instead of {member_id}. If I remember correctly it's parsed early and so should be available to your conditional.

share|improve this answer
    
Thanks for the reply unfortunately I have already tried both (mentioned above) – sheferd Oct 22 '15 at 8:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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