vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Usergroups (https://vborg.vbsupport.ru/showthread.php?t=174453)

lasto 03-28-2008 08:09 PM

Usergroups
 
Say i have 20 users in one usergroup - how can i call the amount of users in one specific usergroup so i can use that info on my index.php page.

I just want to grab the amount of users in one specific usergroup and display the info on main page so it looks something like this :

Admins : 7 (if that is the correct number)

Is this possible ......

--------------- Added [DATE]1206807835[/DATE] at [TIME]1206807835[/TIME] ---------------

anyone know a way to pull this off - i know its not a big request :)

lasto 03-30-2008 06:46 AM

/me bumps this again

Opserty 03-30-2008 11:33 AM

Check the Usergroup.php page in the AdminCP to see how vBulletin does it.

I'm not sure if the count is stored in the usergroup cache, (run a var_dump() of $vbulletin->usergroupcache to see if it is present).

If it doesn't then you best bet is to run a query to count the users in each usergroup and run this on the usergroup.php page or as a scheduled task to update a cache in the datastore. (You don't want to be querying the database on every page load when the data is going to be fairly static).

I'll see if I can give you some more information later, when I boot up my dev vBulletin, but this should give you an idea of what to do/look for.

lasto 03-30-2008 04:37 PM

cheers m8 as all i want the code for is to call on index.php to show how many users are in one particular usergroup.

Opserty 03-30-2008 05:15 PM

Hmm by the looks of it, it isn't stored in the usergroup cache. Here is the query I pulled from the usergroup admin page:
PHP Code:

    // count primary users
    
$groupcounts $db->query_read("
        SELECT user.usergroupid, COUNT(user.userid) AS total
        FROM " 
TABLE_PREFIX "user AS user
        LEFT JOIN " 
TABLE_PREFIX "usergroup AS usergroup USING (usergroupid)
        WHERE usergroup.usergroupid IS NOT NULL
        GROUP BY usergroupid
    "
); 

You could change the WHERE clause to select just what you want.

Have a read of this as you'll probably just want to cache the results to save on queries and processing time. Cache System Explanation (datastore)

lasto 03-30-2008 06:38 PM

bit to much for me m8 how can i use the above info to show the stat i want without it sounding to over complicated :)

and thanks as well

Dismounted 03-31-2008 05:19 AM

The simple way, without using the cache (bad for load-heavy sites, and bad in general coding practise!):
PHP Code:

// count users in usergroup 7 (primary usergroups only)
$groupcount $vbulletin->db->query_read("
    SELECT COUNT(userid)
    FROM " 
TABLE_PREFIX "user
    WHERE usergroupid = 7
"
);
$groupcount $groupcount['userid']; 


lasto 03-31-2008 03:00 PM

i would add that code to my index.php is that correct : now what code would i need to call it into the board

Opserty 03-31-2008 04:17 PM

Put that code in a FORUMHOME hook. Like forumhome_complete or something like that.

Then you just need to add $groupcount in your FORUMHOME template. Like:
Code:

Adminstrator: $groupcount

lasto 04-01-2008 03:51 AM

thanks m8 will try this tonight when get back from work.


All times are GMT. The time now is 02:35 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01075 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete