View Full Version : Check Thread Starter Usergroup and Execute Code
Abhik
02-14-2012, 05:16 PM
Hello,
How do I check the thread starter's usergroup and execute code based on that?
I mean, something like this:
<vb:if condition="is_member_of($threadstarter, 5,6,7,9)">
........
<vb:else />
.............
</vb:if>Is there any possible way?
Punjabi Munda
02-14-2012, 08:17 PM
yes where exactly do you want to do this? The is_member_of should go into your php file and set a boolean to true or false and you can use if statement in your template to behave accordingly
Abhik
02-15-2012, 07:20 AM
Well, its in a template, the threadbit template actually.
Lynne
02-15-2012, 03:32 PM
The $threads query (used to get information for the threadbit template) does not grab the threadstarter's information (like the usergroup). So, you would actually need to add another query per threadbit per page in order to grab that information.
Abhik
02-16-2012, 04:36 PM
The $threads query (used to get information for the threadbit template) does not grab the threadstarter's information (like the usergroup). So, you would actually need to add another query per threadbit per page in order to grab that information.
Thanks Lynne,
What that query should be? Sorry, but I am totally lost here.
Lynne
02-17-2012, 01:19 AM
To be honest, I would not suggest doing that. Is there some other way to do what you want? What is your goal?
Abhik
02-18-2012, 10:11 AM
To be honest, I would not suggest doing that. Is there some other way to do what you want? What is your goal?
Hello Lynne, sorry for replying late.
My goal is to highlight the threadbit in a separate color if the thread started by a member belongs to a specific group.
That's it.
I think the issue is that you normally try not to add queries because they take up time. The user table is already joined in that query to get the info for the last poster, which may be why there's not usergroup coloring for thread starters by default. Anyway, you could just add a query at threadbit_display to look up the info, but then you're adding one query for each thread. The other thing you could do one "big" query similar to the one that's being done (I'm looking in forumdisplay.php), maybe at forumdisplay_query. I don't know which one's better, it probably depends on a lot of factors.
Anyway, if you didn't care at all about adding queries I think you could do this at threadbit_display:
$starterinfo = fetch_userinfo($thread['postuserid']);
$thread['starter_musername'] = fetch_musername($starterinfo);
Then you could use {vb:raw thread.starter_musername} in the template. That assumes that what you want is to have the username colored by group in the same way that it would be in other places. (I haven't tried the above code).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.