View Full Version : If condition which returns true if the creator of a post belongs to usergroup
GrenadeSpam
07-29-2015, 11:28 AM
For our forums (VB5), I'd like to give staff members a differently coloured backgrounds in their posts. To this end, I'd like to add the HTML class "staffPost" to each post made by a staff member (usergroupid 5 or 6).
I've spent an entire afternoon searching for the right condition, but can't seem to find it. Any help would be greatly appreciated.
In pseudo code:
<vb:if condition="owner of this post belongs to usergroup 5"> staffPost</vb:if>
delicjous
07-30-2015, 10:52 AM
If you would try to change css you should do this by somthing like this in additional.css:
<vb:if condition="!empty($user['userid']) AND $user['usergroupid'] = 5 OR $user['usergroupid'] = 6">
backgroundcolor: #000;
</vb:if>
So you don't change code in vB-files.
This might help a little bit:
http://forum.vbulletin-germany.com/showthread.php/24195-Conditionals-Template-Bedingungen
GrenadeSpam
07-31-2015, 10:38 AM
I didn't know if conditionals worked in the CSS as well, that's great!
The code you provided doesn't seem to accomplish what I'd like it to, though. This changes the background colour of a post when the user viewing it belongs to group 5 or 6. What I'd like it to do, is change the background colour of posts if the owner of that post belongs to group 5 or 6. Do you happen to know what conditional I could use for that? I can't seem to find it in the thread you linked to...
delicjous
07-31-2015, 11:16 AM
Sorry, didn't got it right.
Look into all templates named like conversation...
but that should be a little more tricky... have to change the class in code if conversation userid is in usergroup 5 or 6 and make new css-stuff for that staff-class...
This is what I found right now... but I don't think there is something with $conversation['groupid'] at vb-original-code.
<vb:if condition="isset($conversation['edit_userid']) AND !$conversation['unpublishdate']">
<vb:if condition="!$conversation['userid']">
If you don't find anything in the code or forums you could ask again and I will think about.
If you find something it would be nice to share it. ;-)
GrenadeSpam
07-31-2015, 02:07 PM
I can't seem to find anything thus far, I think I'll might just have to do it the lousy way and hardcode the user ID's into the template...
GrenadeSpam
08-04-2015, 11:57 AM
Glenn Vergara provided me with a good solution over at vbulletin.com:
{vb:data posterInfo, user, fetchUserinfo, {vb:raw conversation['userid']}}
<vb:if condition="$posterInfo['usergroupid'] == 5 OR $posterInfo['usergroupid'] == 6">staffPost</vb:if>
This does exactly what I wanted it to do! :)
http://www.vbulletin.com/forum/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4325899-if-condition-which-returns-true-if-the-creator-of-a-post-or-comment-belongs-to-usergroup-x?p=4326328#post4326328
delicjous
08-04-2015, 03:38 PM
Glenn Vergara provided me with a good solution over at vbulletin.com:
{vb:data posterInfo, user, fetchUserinfo, {vb:raw conversation['userid']}}
<vb:if condition="$posterInfo['usergroupid'] == 5 OR $posterInfo['usergroupid'] == 6">staffPost</vb:if>
This does exactly what I wanted it to do! :)
http://www.vbulletin.com/forum/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4325899-if-condition-which-returns-true-if-the-creator-of-a-post-or-comment-belongs-to-usergroup-x?p=4326328#post4326328
Thanks for post it here.
Looks great and usable in many ways.:)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.