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.

Private Comments

August 17, 2011 8:10am

Subscribe [4]
  • #1 / Aug 17, 2011 8:10am

    c@sey

    40 posts

    Hi, I’m using a Safecracker to accept trouble tickets containing somewhat sensitive information from my users. I was hoping to simply use the native EE commenting system as a means of follow up and replies.

    I’m able to hide the submitted entry using the author_id=“CURRENT_USER” parameter, however I cannot find a way to suppress the comments to only admins and the entry author.

    Any suggestions?

  • #2 / Aug 17, 2011 8:59am

    did you try

    {if logged_in_group_id == "1" OR  logged_in_member_id == author_id}
    your code..
    {/if}

    it should work this way..

    dmitry

  • #3 / Aug 17, 2011 9:26am

    c@sey

    40 posts

    Thanks Dmitry, But unfortunately author_id is not available outside of the channel:entries tag. If I display it in the comment:entries tag, it only returns the author’s comments, not any of the support staff. If I were able to get the author_id based on the url segment, I could probably trick the parse order with an embed and some PHP, but I’m hitting walls everywhere I go.

  • #4 / Aug 17, 2011 9:38am

    Why do you need it outside channel:entries tag? You can show comments inside this tag and make use of author_id. Surely you can get author_id based on segment, just provide {last_segment} for {url_title} in {exp:channel:entries} tag and should be working.. Or may be i miss something?

  • #5 / Aug 17, 2011 9:55am

    c@sey

    40 posts

    I’ve tried that and it works, but it seems very buggy. I just figured I was doing something wrong.

    When I use the code below, it displays all comments as if they were from the same author:

    {exp:comment:entries sort="asc" orderby="date" limit="150" channel="tickets" entry_id="{segment_3}"}
    {if author_id == "1"}
        <li id="admincomment">
    {if:else}
        <li id="{comment_id}">
    {/if}
    <div class="comment-author vcard">
        {exp:gravatar email=
    </div>
    <div class="comment-meta">
      <strong>
          Posted on {comment_date format="%M %d, %Y"} by 
          {if author_id == "1"}
          {url_as_author} - (Site Administrator)
          {if:else}
          {url_as_author}
          {/if}
      </strong>
     {comment}
    </div>
    </li>
    {/exp:comment:entries}

    Edit: EE stripped out some of my code.
    Here’s the pastebin: http://pastebin.com/raw.php?i=dA2NKr8z

  • #6 / Aug 17, 2011 10:12am

    it looks almost ok to me.. just don’t forget author_id in comment:entries is the author of certain comment, it’s not the author of an entry.

    i would try this..

    {exp:channel:entries channel="mychannel" url_title="{last_segment}" dynamic="yes" limit="1"}
    {if logged_in_group_id == "1" OR  logged_in_member_id == author_id}
    
    comments go here..
    
    {/if} 
    {/exp:channel:entries}
  • #7 / Aug 17, 2011 10:20am

    i’m sorry, small note about my example: if you provide entry_id and not url_title as i did so put dynamic=“no”.

  • #8 / Aug 17, 2011 10:39am

    c@sey

    40 posts

    Thanks for your help. I’m much closer now. AT least I’ve got the comments private.

    I wanted to be able to use Gravatar and some other dynamic user data but apparently very few of the member variables honor the comment author ID within the exp:entries tag.

  • #9 / Aug 17, 2011 11:11am

    no problem. i always put exp:comment:entries in embeded template (tried this?), this way almost all of the member variables hopefully will work.

  • #10 / Aug 17, 2011 8:38pm

    Dan Decker

    7338 posts

    Hi there c@sey,

    Have Dmitry’s suggestions got you all squared away? Let us know if you need further assistance.

    Cheers,

  • #11 / Aug 18, 2011 1:14pm

    c@sey

    40 posts

    @Dan Yes, thank you. The embed method was the ticket.
    @Dmitry Really appreciate the help. I have a solid ticket system using EE now, many thanks to you.

  • #12 / Aug 20, 2011 12:32am

    Dan Decker

    7338 posts

    c@sey,

    Congratulations! It’s always rewarding to see people being successful with ExpressionEngine.

    Dmitry, thanks for your help on this!

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases