We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

NEW - Group Comment Plugin…

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

I made this plugin exceptionally quickly in reply to a thread here.

Igor wanted a way to be able to style comments from a certain group differently to everyone elses.

This plugin should hopefully address that need. Whilst it is possible to style the original entry authors comments differently (scroll down to see my method 😉 ) this plugin allows you to style all members of a certain group differently.

Usage Instructions :

CSS Code

.group-comment {
        text-transform: uppercase;
}
.not-a-group-comment {
        text-transform: lowercase;
}

Obviously the CSS can be anything you need and you can use DIVs and anything else that you like in between the conditional shown below to lay out your comments just the way you want them

ExpressionEngine Code - Goes inside {exp:comment:entries} tag pair

{exp:group_comment member_id="{author_id}" group_id="1"}
{if belongs_to_group}
{comment}
{if:else}
{comment}
{/if}
{/exp:group_comment}

Hope that helps someone somewhere. As mentioned before this was written in about 2 minutes so hopefully should work 😉

Best wishes,

Mark

       
Danny T.'s avatar
Danny T.
426 posts
17 years ago
Danny T.'s avatar Danny T.

Mark,

Good contribution! Couldn’t this work already? By running a conditional like so:

{if group_id != "1" AND group_id != "6"}
  Regular Comment
{if:else}
  Super Admin / Editor group Comment

Managed to get it to work, but took me time to figure out to use an AND rather than a OR.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Well that’s just not fair if it does work as I couldn’t see a group_id anywhere in the comment entries variables tag pair listed in the documents :down:

I just did a really quick cursory test and it seems as though what you have there does work! All my time wasted making the plugin due to either something missing in the documents or me not looking properly?

I may still be wrong as it was a really quick test though.

Sheesh am I going to be upset if I did all that just to find out there is a group_id variable that I have missed somewhere!!!

Best wishes,

Mark

       
Fatfree's avatar
Fatfree
40 posts
16 years ago
Fatfree's avatar Fatfree

When I attempt to use {group_id} it returns the same regardless of the posters group.

       
Danny T.'s avatar
Danny T.
426 posts
16 years ago
Danny T.'s avatar Danny T.

dchrist,

I can confirm that my original method listed above does work. I’ve had it used in live examples before. Alas, I’ve yet to try it on new builds of EE but will give this a shot and will update this thread with results.

       
siffring's avatar
siffring
147 posts
15 years ago
siffring's avatar siffring

The {group_id} appears to return the group id of the currently logged in user, not the group id of the comment’s author. For some reason, the comments module doesn’t return the comment author’s group id.

I took the liberty of updating this plugin to support multiple groups. So, if you want to check if an author is a member of one of three groups you could do something like this.

{exp:group_comment member_id="{author_id}" group_id="1|6|8"}
    {if belongs_to_group}
        I am in one of these groups!
    {if:else}
        I am not in one of these groups.
    {/if}
{/exp:group_comment}

Beware that this plugin adds a sql query for every comment on the page. Turning on caching for that template will help.

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
15 years ago
Matt Weinberg's avatar Matt Weinberg

Thanks for doing that Jason, very helpful.

Edit: I took my previously modified version down because of a possible bug with the caching.

-Matt

       
Compass Media's avatar
Compass Media
14 posts
15 years ago
Compass Media's avatar Compass Media

Thanks guys, this helped a ton!

       
siffring's avatar
siffring
147 posts
15 years ago
siffring's avatar siffring

Matt, would you mind updating this thread if you get the bug worked out? Caching would be a great addition.

       
Brent Cartier's avatar
Brent Cartier
87 posts
15 years ago
Brent Cartier's avatar Brent Cartier

The problem with this plugin seems to be that both group_id and author_id default to the post’s author_id and group_id when the comment is made by non-member. Anyone have any ideas on how to work around that issue?

It seems that the comment:entries tag should really have completely separate variables for these like comment_author_id and comment_group_id. It would be a good FR, but in the meantime, it seems I have no way to differentiate member and non-member comments… I really wanted all of our members to be able to reply as a common voice - so guest comments would show their name and anyone in specific member groups would be able to reply as “The Company”.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.