ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Show info ONLY to entry author?

July 26, 2012 4:16pm

Subscribe [3]
  • #1 / Jul 26, 2012 4:16pm

    Matthew81

    81 posts

    I want to show some content on the front end ONLY to the author of an entry.  Although the documentation only mentions ‘member_id’ in context of the currently logged-in user, it appears using it within the Channel Entries tag uses the member_id of the author, so that the following always evaluates to true:

    {exp:channel:entries channel="news"}
     {if {member_id} == {author_id}}
      Show this content
     {/if}
    {/exp:channel:entries}

    I’ve tried setting a Stash variable for each, but somehow I can’t get the variables to work inside a conditional (have posted on the Stash forum about that).

    I’d be very grateful for any and all ideas on how to show content only to an entry’s author.

    Thanks,

    Matthew

  • #2 / Jul 26, 2012 5:18pm

    John St-Amand

    865 posts

    a long shot, but have you tried it without the parentheses around each variable?

    {if author_id == member_id}
    show this content to logged in author
    {/if}

    I find on occasion EE is sensitive to these seemingly little differences.  Hope that helps.

  • #3 / Jul 26, 2012 5:54pm

    tidy

    196 posts

    Hi Matthew,

    I’ve never needed to do this myself, but I remembered something about needing to use a different syntax for member variables within channel tags to avoid conflicts. I think the info here might do the trick:
    http://ellislab.com/expressionengine/user-guide/templates/globals/conditionals.html#alternative-syntax

    As per the code sample there try:

    {if logged_in_member_id == author_id}
    Show this content
    {/if}
  • #4 / Jul 26, 2012 6:02pm

    Matthew81

    81 posts

    I hadn’t thought of that, but unfortunately the conditional still always evaluates to true.

    There has got to be a way to do this…

    EDIT: Cross-posted with tidy’s post, will go try that now.

  • #5 / Jul 26, 2012 6:07pm

    Matthew81

    81 posts

    That did it - thanks so much! 😊

  • #6 / Jul 26, 2012 6:10pm

    tidy

    196 posts

    Glad that worked for you Matthew - it’s fairly hidden in the docs

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases