PDA

View Full Version : Need help with "threads starter" template conditional


vbplusme
02-17-2009, 08:03 PM
In the threadbit, I have this piece of code:

<span style="cursor:pointer" onclick="window.open('member.php?$session[sessionurl]u=$thread[postuserid]', '_self')">$thread[postusername]</span>

I want to wrap a condtional around it to test if the thread starter is an administrator and add a title to the display.

Can this be done with template conditionals, if so, which one? All the ones I have tried test for the user rather than the thread starter.

I am thinking something like :

<if condition="$threadstarter = usergroupid 5,6">

for example. Does a template conditional exist for this kind of test?

TIA for any suggestions.

Lynne
02-18-2009, 12:27 AM
Try:
<if condition="is_member_of($thread[postuserid], 6)">stuff</if>

vbplusme
02-18-2009, 02:34 AM
Thanks Lynne, I tried it and got unexpected results. I thought it worked at first. I expected that only the administrators would be selected but it also select post from one of the registered users who is not an administrator.

If I do an explicit "<if condition="$thread['postuserid'] == 1">" only the administrator posts are correctly selected but what I want is to be able to select the usergroupid to which $thread[postuserid] belongs.

When I changed you example to 2 thinking it would select all the "registered users", it didn't select any even through some do exist.

Any ideas?

Lynne
02-18-2009, 02:55 AM
Now that I relook at that condition, I can see it won't work. It needs the usergroupid, not the id of the user. Instead of $thread[postuserid], you can try $thread[groupuserid] or just $thread, but I don't think the usergroupid is ever grabbed. And, if it isn't, then you will have to get it with the help of a plugin you write.

vbplusme
02-18-2009, 05:00 AM
That's what I thought just needed to verify it. thanks very much.

Dismounted
02-18-2009, 05:52 AM
When you grab the user info, you will want to fetch all the info for the threads all in one query.

vbplusme
02-18-2009, 10:00 AM
Thanks, I haven't started on the query yet, are you thinking I need a join? I was thinking that I would try to do a select on user where userid = $thread[postuserid] and grab the usergroupid from there, like

$getUserGroup= $vbulletin->db->query_read("SELECT usergroupid FROM `user` WHERE `userid`= $thread[postuserid]);



then I will test for what usergroup and assign it to a $is_admin variable for example.

I only have 4 usergroups that I care about so it not that big of a problem. I would wrap the conditional around my display code:

<if condition="$is_admin">

I got sidetracked with it because I was trying to use user conditions on a variable value test so it either selected all threads or none. So I am thinking that the thread starter is a variable I should be able to test for to find out what group they are in then add a title or image next to the name in the thread display.

I am thinking that the threadbit_display hook, should that be correct?

If you are thinking something different, I'd be glad to hear about it.

thanks, Michael

Lynne
02-18-2009, 03:26 PM
Look for the query in forumdisplay that grabs all the threads to display there. Right above the query is hopefully a hook. Use that hook to grab the usergroupid of the thread starter.