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.

How Do I: Display member data in a comment "byline", even to non-member visitors

July 05, 2012 3:26pm

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

    Lesli

    92 posts

    Hello all,

    I am trying to display a commenter’s Twitter URL, Facebook URL, and site URL, and avatar above every comment they make.

    I also want to display a different message for banned members.

    I got this code to work…but now, in 2.5.2, I’m noticing that it displays one way when I’m logged in, and doesn’t display any of that information when I’m logged out. Is this expected behavior for EE? (If so, I need to change my code. If not, I need to speak with the plugin developer.)

    Here’s the code I’m using:

    <div class="commenthead">{exp:member:custom_profile_data}
    {if avatar}{avatar_url}{/if}
    {if '{group_id}' != '2'}{url_or_email_as_author} 
    {if url != ''}<a href="http://{url}" target="_blank" rel="noopener">http://images.sparklecrackcentral.com/site_images/icon_32x32_site.png</a>{/if}
    {if twitter != ''}<a href="https://twitter.com/{twitter}" target="_blank" rel="noopener">http://images.sparklecrackcentral.com/site_images/icon_32x32_twitter.png</a>{/if}
    {if fb_page != ''}<a href="http://{fb_page}" target="_blank" rel="noopener">http://images.sparklecrackcentral.com/site_images/icon_32x32_facebook.png</a>{/if}
    {/if}
    {if '{group_id}' == '2'}{username} (Member has been banned){/if} :: 
    {comment_date format="%Y-%m-%d"}{/exp:member:custom_profile_data}
    </div>

    Here are two screenshots: the first, the comment heading as it displays when I’m logged in. The second, as the same comment heading displays when I’m logged out. I want the comment masthead to display whether a user is logged in or logged out.

    I *think* that this worked just as I expected it to, in EE 2.4. I didn’t check again after upgrading to EE 2.5.2. I am using the latest version of the Threaded Comments plugin (2.3.9).

    Based on the code above, and the screenshots, is the current behavior expected for the code that I used, or is something going wrong?

  • #2 / Jul 06, 2012 11:16am

    Shane Eckert

    7174 posts

    Hello Lesli,

    I am sorry to hear you are running into this problem.

    Custom Profile Data can rely on being logged in. Or you can use mameber_id=”” for a specific user.

    The data can either be shown from the currently logged-in user or from a specified user using the member_id=”” parameter.

    I hope this helps!

    Cheers,

  • #3 / Jul 06, 2012 12:44pm

    Lesli

    92 posts

    Hi Shane,

    So then, what code would I use if I wanted to display the following information:

    Commenter name (commenter’s URL | commenter’s Twitter | commenter’s Facebook)

    but if a particular member had been banned, display the following information:

    Commenter name [this member has been banned]

  • #4 / Jul 09, 2012 4:31pm

    Shane Eckert

    7174 posts

    Hey Lesli,

    I talked to Dan, we have a pretty nifty way.

    Use the comment entries loop and the author_id to get who the comment belongs to. Use that as an embed to pull this all together.

    Does that make sense?

    Cheers,

  • #5 / Jul 09, 2012 9:46pm

    Lesli

    92 posts

    ...sort of. I’m using the threaded_comments plugin, though, so I’m going to have to hope that that works. (The fact that it worked in 2.4, and doesn’t now, is more than a little annoying.)

    Embedded templates can still handle the conditional tags, right? The if ‘group_id’ == 2 bit, to show one type of content if that commenter is in the Banned group and show their links elsewise - that should still work, right?

    And - do I just embed the code I have, or does the code I have, need to be rewritten? AFAIK, I need to use the exp_custom_member_data tag because I want to pull profile-field data for fields that I’ve added (FB and Twitter URLs.) Correct?

  • #6 / Jul 11, 2012 2:31pm

    Shane Eckert

    7174 posts

    Hey Lesli,

    I hear you on the annoying thing. I wish more was ported over more consistently as well.

    Yes, embedded templates handle conditionals, just watch where they are being included and keep an eye Parse Order. It’s snippets that you are thinking of.

    That group_id conditional should work.

    I think your code needs some tweaking, especially since you are going for author_id. If you can have less conditionals that will help as well. To be honest, I would keep this thread here with me in support but I would just post your code to the Community Help Forum and see what some of the master minds come up with. The community loves their code.

    Please let me know how this comes together and if there are any more issues that arise.

    Cheers,

  • #7 / Jul 11, 2012 5:09pm

    Lesli

    92 posts

    So I’ve added in the member_id=”{member_id}” attribute onto the custom_member_data tag…and the exact same behavior is taking place. That doesn’t change things one way or the other. So that’s not quite the issue.

    And - if I understand it - I have to use that tag to display the custom fields from a person’s profile, correct? (Their FB, Twitter, and standalone site link)?

  • #8 / Jul 11, 2012 6:11pm

    Lesli

    92 posts

    Okay - I’ve edited the code slightly so that only the FB and Twitter links are within the custom_member_data tag…and the rest of it shows up as expected. But the custom profile fields still don’t show up, not even when I tried putting that code into an embed (a template, not a snippet) and pulling them in that way.

    The banned-member switch isn’t happening any more, either. I had gone to the developer, who suggested a fix that worked…until I upgraded from 2.4 to 2.5.2.

  • #9 / Jul 11, 2012 11:40pm

    Lesli

    92 posts

    The latest:

    I’ve rearranged the code somewhat. Now the author_as_url is always displaying; it doesn’t display just the username and “The user has been banned” if their {group_id} == 2. It always displays the first option.

    
    									
  • #10 / Jul 12, 2012 2:26pm

    Shane Eckert

    7174 posts

    Hi,

    Can you talk with the developer again? Maybe he can get it working for 2.5.2?

    Here is what I was talking about with the embed.

    Put this in an embed.

    {exp:member:custom_profile_data member_id="{my_id}"}
    {if twitter != ''}<a href="https://twitter.com/{twitter}" target="_blank" rel="noopener">http://images.sparklecrackcentral.com/site_images/icon_32x32_twitter.png</a>{/if}
    {if fb_page != ""}<a href="http://{fb_page}" target="_blank" rel="noopener">http://images.sparklecrackcentral.com/site_images/icon_32x32_facebook.png</a>{/if}
    {/exp:member:custom_profile_data}

    Then pass this into the embed variable.

    my_id = '{author_id}'

    That will give you the member id.

    Make sense?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases