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 Answers 2

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.

0
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}"}

6
  • That's what I thought too, and it works if one author is selected, but not two or more.
    – Blair
    Mar 21, 2013 at 19:35
  • Hmm. I'm guessing creating member groups is not going to help your case? Mar 21, 2013 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, 2013 at 21:21
  • Does the {members_field} tag pair inside of a preload variable work? ellislab.com/expressionengine/user-guide/templates/globals/… Mar 21, 2013 at 22:00
  • It passes, but does not solve the problem.
    – Blair
    Mar 22, 2013 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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