![]() |
|
Thread Tools |
#1
|
||||
|
||||
Check usergroup of thread starters in threadbit
I'm looking for an if condition that can check for the usergroup of the thread starter for each thread in the thread list via the threadbit template.
In posts I show certain content in the postbit_legacy template that only shows if the thread starter is in a certain usergroup. For that I use the following condition (where 60 would be the usergroup id)
However I this condition doesn't work in the threadbit template. Just edited this, I just need a thread starter conditional for the threadbit template. No members have liked this post.
Last edited by addamroy; 25 Feb 2013 at 16:08. |
#2
|
|||
|
|||
Anyone?
No members have liked this post.
|
#3
|
|||
|
|||
Try using $thread['usergroupid']. I don't know how it gets there, but it looks like it's there.
No members have liked this post.
|
#4
|
|||
|
|||
That's actually pulling the usergroup ID of the last post... for some reason. Instead of the thread starter.
No members have liked this post.
|
#5
|
|||
|
|||
Well, in that case you'd need to have a plugin get the usergroup and set a field that you can test in the template.
The following members like this post: addamroy
|
#6
|
|||
|
|||
Hmm that makes sense. Unfortunately all I know for php and vb coding is if-else conditions lol, learning though. Can you give me some guidance on how to accomplish the usergroup check via a bulletin, so i can use a condition in the threadbit template for it?
No members have liked this post.
|
#7
|
||||
|
||||
Try this everywhere in threadbit template: <vb:if condition="$thread['usergroupid'] == 60">Your text here</vb:if>
__________________
I am on holiday (18 Jan to 14 Feb), so I can't complete your requests in time, sorry guys, hope next time you still hire me. Thanks PM me for custom paid modifications for your vB3/vB4 forums ... ![]() No members have liked this post.
|
#8
|
|||
|
|||
We already tried that suggestion (via a post above), unfortunately that checks the usergroup of the last poster, not the thread starter.
No members have liked this post.
|
#9
|
||||
|
||||
Unfortunately, looking at the query shows me the there is a JOIN with the user table based on the lastposterid, not the postuserid. This means you would need to write a query to find out the usergroup. That is one query per thread listed. It's a simple query which will probably be just fine on a non-busy site or one that is not on an overloaded shared server, but it's something you should think about.
__________________
Former vBulletin.org Staff Member
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before. W3Schools - Online vBulletin Manual If I post some CSS and don't say where it goes, put it in the additional.css template. I will NOT help via PM (you will be directed to post in the forums for help.) No members have liked this post.
|
#10
|
|||
|
|||
I'm not a php guru dude at all, I just have a vague understanding of the basics and can only write the most basic of code (like I'll go back and forth from dreamweaver to php.net copy/pasting etc
![]() There is not ANY data available in threadbit besides the username of the threadstarter? Wouldn't it be simple enough just to add each username to an array, then check all the usernames in the array and and assign their usergroups with one query, before each individual thread is loaded? Like I said I don't know too much about PHP and wouldn't know how to create such a function, but since the username is available and there are no duplicate usernames in the db couldn't it be done by creating one array and executing one query with it? No members have liked this post.
|
#11
|
||||||||
|
||||||||
create new plugin
Hook Location: threadbit_display Title: usergroup check for threadstarter in threadbit Plugin PHP Code:
then in template threadbit You could do
The 6 being the group you want to check, and this example 6 is the Administrator group. This checks the primary and additional groups of a thread starter.
__________________
If I have helped you, the least you could do is click the ❤ button to show your appreciation. ![]() TheSecond.org - Because it is our right! No members have liked this post.
|
#12
|
|||
|
|||
Thanks!
Like Lynne said about the additional queries, I really only want to do this one or two sections of the forum. Is there anyway to have the plug-in only run that query for specific forums? No members have liked this post.
|
#13
|
||||
|
||||
change 1,2,3 to forums you want it to run in.
__________________
If I have helped you, the least you could do is click the ❤ button to show your appreciation. ![]() TheSecond.org - Because it is our right! The following members like this post: kh99
|
#14
|
|||
|
|||
When I go to save the threadbit template after inserting your if conditional, I get the following error message:
"Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3568 Forum Message The following error occurred when attempting to evaluate this template: %1$s This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish." No members have liked this post.
|
#15
|
||||||||
|
||||||||
Originally Posted by kh99
As is, if you do a var_dump on $groups it shows the proper primary and secondary groups of the threadstarter.![]()
The code works, I just messed up the "Specific forums" conditional. if (in_array($thread['forumid'], array(1,2,3))) please review other mods and vB code for proper usage. But other than that, the code is sound, and taken directly from forumdisplay.php --------------- Added 25 Feb 2013 at 16:54 ---------------
Originally Posted by addamroy
you must be doing something wrong because the code is tested as working 100% on vanilla vbulletin 4.2 pl3![]()
--------------- Added 25 Feb 2013 at 16:55 --------------- i didnt even mess up the conditional it all works 100% --------------- Added 25 Feb 2013 at 16:59 --------------- It was throwing an error, try this code
__________________
If I have helped you, the least you could do is click the ❤ button to show your appreciation. ![]() TheSecond.org - Because it is our right! No members have liked this post.
|
![]() |
«
Previous Thread
|
Next Thread
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 03:09.