Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 19 Feb 2013, 17:34
addamroy addamroy is offline
 
Join Date: Sep 2010
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)


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.

Last edited by addamroy; 25 Feb 2013 at 15:08.
Reply With Quote
  #2  
Old 21 Feb 2013, 12:21
addamroy addamroy is offline
 
Join Date: Sep 2010
Anyone?
Reply With Quote
  #3  
Old 21 Feb 2013, 12:59
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Try using $thread['usergroupid']. I don't know how it gets there, but it looks like it's there.
Reply With Quote
  #4  
Old 23 Feb 2013, 12:26
addamroy addamroy is offline
 
Join Date: Sep 2010
That's actually pulling the usergroup ID of the last post... for some reason. Instead of the thread starter.
Reply With Quote
  #5  
Old 23 Feb 2013, 13:40
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #6  
Old 24 Feb 2013, 17:58
addamroy addamroy is offline
 
Join Date: Sep 2010
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?
Reply With Quote
  #7  
Old 24 Feb 2013, 19:06
mokujin's Avatar
mokujin mokujin is offline
 
Join Date: Nov 2005
Real name: Đạt
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 ...
Reply With Quote
  #8  
Old 24 Feb 2013, 22:34
addamroy addamroy is offline
 
Join Date: Sep 2010
We already tried that suggestion (via a post above), unfortunately that checks the usergroup of the last poster, not the thread starter.
Reply With Quote
  #9  
Old 24 Feb 2013, 23:03
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
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.)
Reply With Quote
  #10  
Old 24 Feb 2013, 23:51
addamroy addamroy is offline
 
Join Date: Sep 2010
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 ) but i do understand what you mean.

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?
Reply With Quote
  #11  
Old 25 Feb 2013, 04:46
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
create new plugin

Hook Location: threadbit_display
Title: usergroup check for threadstarter in threadbit
Plugin PHP Code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then in template threadbit

You could do

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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!
Reply With Quote
  #12  
Old 25 Feb 2013, 14:43
addamroy addamroy is offline
 
Join Date: Sep 2010
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?
Reply With Quote
  #13  
Old 25 Feb 2013, 14:48
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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!
Reply With Quote
  #14  
Old 25 Feb 2013, 15:01
addamroy addamroy is offline
 
Join Date: Sep 2010
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."
Reply With Quote
  #15  
Old 25 Feb 2013, 15:47
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Originally Posted by kh99 View Post
Kudos to LifesGreatestGift for writing the plugin. But I think there may be one small problem: on this line:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I think you want thread.postuserid instead of thread.firstpostid.
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 15:54 ---------------

Originally Posted by addamroy View Post
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."
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 15:55 ---------------

i didnt even mess up the conditional it all works 100%

--------------- Added 25 Feb 2013 at 15:59 ---------------

It was throwing an error, try this code


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View 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!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 01:54.

Layout Options | Width: Wide Color: