2

I'm using a multi-author field (VZ Members) that outputs this for author IDs;

4333|3871|3957

How can I show entries that match the logged in user? Something like:

If logged_in_member_id matches one of these, 4333|3871|3957, then show entry.

Is there a built-in EE way or does this jump to embedded php? (I hope this question isn't too trivial... it feels that way)

2

For a normal conditional to work you would have to write it like this:

{if logged_in_member_id == "4333" || logged_in_member_id == "3871"}

However that's not very flexible and isn't going to work with a piped list of IDs. I've written a custom plugin in the past to solve a similar issue. There's a plugin called Pvl Check If on Devot:ee that I think would work in this situation. Your code using the plugin would look something like this:

{exp:pvl_checkif value="{logged_in_member_id}" is_in="{members_field}{id}|{/members_field}" parse="inward"}
    <p>Yes Sir!</p>
{else}
    <p>No Sir!</p>
{/exp:pvl_checkif}

I'm not sure how the variable pair will go inside the plugin parameter... you may need to play around with it a bit. Perhaps try with hardcoded values first.

| improve this answer | |
1

You should just be able to do {if logged_in_member_id == "4333|3871|3957"}.

Or with VZ Members, which I'm not familiar with, it should be {if logged_in_member_id == "{members_field}{id}|{/members_field}"}

| improve this answer | |
  • That's what I thought too, and it works if one author is selected, but not two or more. – Blair Mar 21 '13 at 19:35
  • Hmm. I'm guessing creating member groups is not going to help your case? – Stephen Callender Mar 21 '13 at 20:01
  • Unfortunately not. They are already in member groups and this would be to give access on a per-entry basis, like an override to the member group. ...and there's going to be a whole lot of entries. – Blair Mar 21 '13 at 21:21
  • Does the {members_field} tag pair inside of a preload variable work? ellislab.com/expressionengine/user-guide/templates/globals/… – Stephen Callender Mar 21 '13 at 22:00
  • It passes, but does not solve the problem. – Blair Mar 22 '13 at 5:41

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.