Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 02 Feb 2014, 10:17
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Total Users In Usergroup

Hello all.
Could anyone point me in the right direction, as to how to show the total number of members in a certain usergroup in a sidebar module and/or on the forumhome.

If it helps, the usergroup number is 12.

Thanks a bunch.
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
Reply With Quote
  #2  
Old 02 Feb 2014, 11:13
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Well, you could do this:

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

Then either pre-register $num_members to a template where you want to use it, or else create a php type block and return some html that includes that variable.

Last edited by kh99; 02 Feb 2014 at 11:26. Reason: added table prefix
Reply With Quote
  #3  
Old 02 Feb 2014, 11:53
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Mmm, thanks i will give it a whirl.
Do you mean add the text you have added as a plugin, then make a new template which can be called via $num_members ?
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
Reply With Quote
  #4  
Old 02 Feb 2014, 12:14
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
If you want to make a forum block, then you can make a php type block and use that code as part of it. If you want to put the value in an existing template, then you need to create a plugin, use that code, and also add a line to pre-register it to the template you want it to display in (and also edit the template to add something like {vb:raw num_members}).

For example, if you wanted to add it somewhere in the FORUMHOME template, you could create a plugin using hook location forumhome_complete and code like this:

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


Then in FORUMHOME, something like:

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


BTW, you wouldn't expect that query to fail, but it's good to check anyway and do something reasonable rather than display 0.

(I changed it to use num_grp_members because I think num_members might be used already).
Reply With Quote
  #5  
Old 02 Feb 2014, 12:30
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, I also meant to mention: that query only works if 12 is the users' primary usergroup. If you're using it as a secondary group it needs to be modified to check the membergroups column.
Reply With Quote
  #6  
Old 02 Feb 2014, 12:41
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Fabulous!! Thankyou. That works great on Forum Home.
I tried the code in a php block, but it causes a white screen of nothingness on the forum.

Not my forte unfortunately.

Thankyou though, i have a starting block at least.
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
Reply With Quote
  #7  
Old 02 Feb 2014, 12:43
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Hmm...you may need to add "global $vbulletin;" to the beginning to use it in a forum block.
Reply With Quote
  #8  
Old 02 Feb 2014, 12:47
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Strange.
I added

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

to a forum block, and it does stop the white screen, but the block doesn't show at all.
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
Reply With Quote
  #9  
Old 02 Feb 2014, 12:51
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Sorry I wasn't clear, it should be:

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


But you also need to return some html to see anything.
Reply With Quote
  #10  
Old 02 Feb 2014, 12:58
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Yes that works, but still not showing the number in sideblock. Would this be correct?

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

__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================

Last edited by Davey-UK; 02 Feb 2014 at 13:02. Reason: Edited to include <br />
Reply With Quote
  #11  
Old 02 Feb 2014, 13:01
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oops, I left out the part where you set $num_grp_members (I think I originally posted it like that then edited the post to fix it). Also, you should use <br /> instead of \n. So, try this:

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

Reply With Quote
  #12  
Old 02 Feb 2014, 13:07
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
Thumbs up

Woop! Fantastic, that works a treat! I was editing my last post to include <br /> as you must have been typing this. LOL
Thankyou so much for this swift answering, its fab. Now for some styling.
Thanks again
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
Reply With Quote
  #13  
Old 09 Jun 2014, 06:39
Davey-UK's Avatar
Davey-UK Davey-UK is offline
 
Join Date: Feb 2003
Location: Sheffield-UK
Real name: Dave
You wouldnt know how to fetch the last paid member username, or even the last 3, and place it in the sidebar with this bit of code would you?
Thanks
__________________
==========================================
If it aint broke -------------------- Don't fix it!!
==========================================
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 02:00.

Layout Options | Width: Wide Color: