1

How can I check that the current user is the author of the post? Something like this?...

{if author_id="CURRENT_USER"}{/if}

(My setup is basically an entries loop, with a snippet inside of that containing all the variables to display each entry. Within that I want to conditionally show an embedded include which holds a delete form. So basically I only want to show the delete form for entries which are authored by the current user. Got it all working okay, just need the conditional now.)

2

Compare to the member_id global variable:

{if member_id == author_id}

Or use the alternative syntax:

{if logged_in_member_id == author_id}

Just remember that global variables are parsed at the end of parsing stages. So, the content inside the conditional will bee removed only after all previous parsing stages. Because of that, you should not put an embed inside it.

| improve this answer | |
  • Ah nice thank you. What about if I was to put it inside the embed, setting variables e.g. {embed:member_id} and {embed:author_id} ? – jx3 Aug 31 '15 at 10:37
  • The problem remains. The point is that you should avoid to parse a complete template to be removed. Try to keep everything inside the snippet. – Robson Sobral Aug 31 '15 at 14:09

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.